How to disable the Enter key

By | January 10, 2017

In this tutorial, Show you how to disable the “Enter” Key. If you have an HTML form on your web page, many times your visitors may hit the ‘Enter’ key on their keyboard.

Disabled Enter Key Example :

<script type=”text/javascript”>
function stopenterKey(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 = stopenterKey;

</script>

Leave a Reply

Your email address will not be published. Required fields are marked *