javascript - Disabling enter key for form -


i have been trying disable enter key on form. code have shown below. reason enter key still triggering submit. code in head section , seems correct other sources.

disableenterkey: function disableenterkey(e){         var key;               if(window.event)             key = window.event.keycode; //ie         else             key = e.which; //firefox                return (key != 13);     }, 

if use jquery, quite smiple. here go

$(document).keypress(     function(event){      if (event.which == '13') {         event.preventdefault();       }   }); 

Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -