禁用输入按钮
Disable enter button
我正在使用以下代码来禁用输入按钮,但它不起作用。当我按 enter 时调用此函数,它也输入 false 但不知何故它仍然无法正常工作。
有没有其他方法可以禁用回车键,请指点。
<script type="text/javascript">
function stopRKey(evt) {
var evt = (evt) ? evt : ((event) ? event : null);
var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
if (evt.keyCode == 13) {return false;}
}
document.onkeypress = stopRKey;
</script>
这是我的 jsp 代码。当我按下回车键时,它会点击 Get Next Work Item ,即 table.
的第一个 div 标签
<table border="0" cellpadding="0" cellspacing="0" width="95%" class="DataTable">
<tr>
<td width="23%" >
<div align="right">
<a Href="" OnMouseOut="isimgact( 'btNextWorkItem',0)" OnMouseOver="isimgact( 'btNextWorkItem',1)" onclick ="return fnNextItem( document.template);">
<img src="<%=PAGEBUTTON%>/GetNxtWorkItm.gif" name= "btNextWorkItem" alt="Get Next Work Item" tabindex="10" width="165" height="25" style="CURSOR: hand" border="0" ondrop="fnDrop()" ondragover="fnOverDrag()">
</a>
</div>
</td>
<td width="2%">
</td>
<td width="23%" >
<div align="Right">
<a Href="" OnMouseOut="isimgact( 'btTransToList',0)" OnMouseOver="isimgact( 'btTransToList',1)" onclick ="return fnSubmitWorkList( document.template,'<%=workList.getNoOfChkBoxes()%>','transferTL','PWL','WorkList');" >
<img src="<%=PAGEBUTTON%>/TnfToTeamLst.gif" name= "btTransToList" alt="Transfer To Team List" tabindex="10" width="165" height="25" style="CURSOR: hand" border="0" ondrop="fnDrop()" ondragover="fnOverDrag()">
</a>
</div>
</td>
<td width="2%"></td>
<td width="23%" >
<div align="Center">
<a Href="" OnMouseOut="isimgact( 'btTnfToSite',0)" OnMouseOver="isimgact( 'btTnfToSite',1)" onclick ="return fnWorkList( document.template,'<%=workList.getNoOfChkBoxes()%>','transferTS','PWL','WorkItemRout');">
<img src="<%=PAGEBUTTON%>/TnfToSite.gif" name= "btTnfToSite" alt="Transfer To Site" tabindex="10" width="165" height="25" style="CURSOR: hand" border="0" ondrop="fnDrop()" ondragover="fnOverDrag()">
</a>
</div>
</td>
<td width="2%">
</td>
<% if (userInfo.getRegion().equals(WebKeys.SHARED_SERVICES_REGION))
{%>
<td width="25%" >
</td>
<% }
else
{
%>
<!-- END Add INFOSYS 29-MAR-2006: REQ P6138b Disabling Imaging Worklist June 2006 release -->
<td width="25%" >
<div align="right">
<a Href="" OnMouseOut="isimgact( 'btNextImagingWorkItem',0)" OnMouseOver="isimgact( 'btNextImagingWorkItem',1)" onclick ="return fnNextImagingItem( document.template);">
<img src="<%=PAGEBUTTON%>/GetImagingItem.gif" name= "btNextImagingWorkItem" alt="Get Imaging Item" tabindex="10" width="165" height="25" style="CURSOR: hand" border="0" ondrop="fnDrop()" ondragover="fnOverDrag()">
</a>
</div>
</td>
<%}%>
</tr>
</table>
尝试:
$(document.body).on("keydown", function(e) {
if ( e.keyCode === 13 ) {
return false;
};
});
我正在使用以下代码来禁用输入按钮,但它不起作用。当我按 enter 时调用此函数,它也输入 false 但不知何故它仍然无法正常工作。 有没有其他方法可以禁用回车键,请指点。
<script type="text/javascript">
function stopRKey(evt) {
var evt = (evt) ? evt : ((event) ? event : null);
var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
if (evt.keyCode == 13) {return false;}
}
document.onkeypress = stopRKey;
</script>
这是我的 jsp 代码。当我按下回车键时,它会点击 Get Next Work Item ,即 table.
的第一个 div 标签<table border="0" cellpadding="0" cellspacing="0" width="95%" class="DataTable">
<tr>
<td width="23%" >
<div align="right">
<a Href="" OnMouseOut="isimgact( 'btNextWorkItem',0)" OnMouseOver="isimgact( 'btNextWorkItem',1)" onclick ="return fnNextItem( document.template);">
<img src="<%=PAGEBUTTON%>/GetNxtWorkItm.gif" name= "btNextWorkItem" alt="Get Next Work Item" tabindex="10" width="165" height="25" style="CURSOR: hand" border="0" ondrop="fnDrop()" ondragover="fnOverDrag()">
</a>
</div>
</td>
<td width="2%">
</td>
<td width="23%" >
<div align="Right">
<a Href="" OnMouseOut="isimgact( 'btTransToList',0)" OnMouseOver="isimgact( 'btTransToList',1)" onclick ="return fnSubmitWorkList( document.template,'<%=workList.getNoOfChkBoxes()%>','transferTL','PWL','WorkList');" >
<img src="<%=PAGEBUTTON%>/TnfToTeamLst.gif" name= "btTransToList" alt="Transfer To Team List" tabindex="10" width="165" height="25" style="CURSOR: hand" border="0" ondrop="fnDrop()" ondragover="fnOverDrag()">
</a>
</div>
</td>
<td width="2%"></td>
<td width="23%" >
<div align="Center">
<a Href="" OnMouseOut="isimgact( 'btTnfToSite',0)" OnMouseOver="isimgact( 'btTnfToSite',1)" onclick ="return fnWorkList( document.template,'<%=workList.getNoOfChkBoxes()%>','transferTS','PWL','WorkItemRout');">
<img src="<%=PAGEBUTTON%>/TnfToSite.gif" name= "btTnfToSite" alt="Transfer To Site" tabindex="10" width="165" height="25" style="CURSOR: hand" border="0" ondrop="fnDrop()" ondragover="fnOverDrag()">
</a>
</div>
</td>
<td width="2%">
</td>
<% if (userInfo.getRegion().equals(WebKeys.SHARED_SERVICES_REGION))
{%>
<td width="25%" >
</td>
<% }
else
{
%>
<!-- END Add INFOSYS 29-MAR-2006: REQ P6138b Disabling Imaging Worklist June 2006 release -->
<td width="25%" >
<div align="right">
<a Href="" OnMouseOut="isimgact( 'btNextImagingWorkItem',0)" OnMouseOver="isimgact( 'btNextImagingWorkItem',1)" onclick ="return fnNextImagingItem( document.template);">
<img src="<%=PAGEBUTTON%>/GetImagingItem.gif" name= "btNextImagingWorkItem" alt="Get Imaging Item" tabindex="10" width="165" height="25" style="CURSOR: hand" border="0" ondrop="fnDrop()" ondragover="fnOverDrag()">
</a>
</div>
</td>
<%}%>
</tr>
</table>
尝试:
$(document.body).on("keydown", function(e) {
if ( e.keyCode === 13 ) {
return false;
};
});