Prevents the return key from submitting the form.


/ Published in: JavaScript
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <script language="javascript" type="text/javascript">
  2. function stopRKey(evt) {
  3. var evt = (evt) ? evt : ((event) ? event : null);
  4. var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
  5. if ((evt.keyCode == 13) && (node.type=="text")) { return false; }
  6. }
  7. document.onkeypress = stopRKey;
  8. </script>

URL: http://www.mediacollege.com/internet/javascript/form/disable-return.html

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.