Wednesday, September 8, 2010

Disable Enter key in Form tag

Placing the following code in your page section will disable the enter key operation in text field



 <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) && (node.type=="text")) {return false;}   
 }   
 document.onkeypress = stopRKey;   
 </script>  
Source : http://www.webcheatsheet.com

No comments:

Post a Comment