Saturday, June 5, 2010

How to disable the Enter key on HTML form

Add following java script code inside the <HEAD> Tag.

<script type="text/javascript">

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;

<script>

No comments:

Post a Comment