From The Blog

Javascript: stop submitting form on pressing ENTER key

28 June 2014, in Javascript

//stop submitting form on pressing enter key

//This code will allow enter key on textarea
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;



Post a Comment