Chris Pinski Chris Pinski - 1 year ago 108
HTML Question

Disabling enter key for form

I have been trying to disable the Enter key on my form. The code that I have is shown below. For some reason the enter key is still triggering the submit. The code is in my head section and seems to be correct from other sources.

disableEnterKey: function disableEnterKey(e){
var key;
key = window.event.keyCode; //IE
key = e.which; //firefox

return (key != 13);

Answer Source

if you use jQuery, its quite smiple. Here you go

     if (event.which == '13') {

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download