Answer the question
In order to leave comments, you need to log in
How to avoid form submission by hitting Enter in HTML???
There is a form. If you press Enter, then it works, but how can you avoid this?
Is it possible to do this with jQuery?
Answer the question
In order to leave comments, you need to log in
function stopRKey(evt) {
var evt = (evt) ? evt : ((event) ? event : null);
var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
if ((evt.keyCode == 13) && (node.type=="text")) {return false;}
}
document.onkeypress = stopRKey;
$('html').bind('keypress', function(e)
{
if(e.keyCode == 13)
{
return false;
}
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question