This topic is locked

How to prevent "enter" button from accidentally submitting a f

8/11/2011 11:07:54 AM
PHPRunner Tips and Tricks
F
FunkDaddy author

Some of my users complained about accidentally submitting a form after they press the "enter" button on their keyboard. Here's a way to ensure form will only submit via a mouse click on a form button:
Add to your forms JS OnLoad event:



//prevent enter key default behavior from submitting form

$(document).keydown(function(event){

if(event.keyCode == 13) {

event.preventDefault();

return false;

}

});


That's all.