rss feed Twitter Page Facebook Page Github Page Stack Over Flow Page

How to disabled the enter key in javascript in a web form

For those who likes to disable the "enter" key when submitting a form, well ... this script is not for you. But for all others who want to know, simply add the following code to your page.

function disableEnterKey(evt) {
  var evt = (evt) ? evt : ((event) ? event : null);
  var node = ( ? : ((evt.srcElement) ? evt.srcElement : null);
  if ((evt.keyCode == 13) && (node.type=="text"))  {return false;}
document.onkeypress = disableEnterKey;