Disable Enter key using Javascript

Disable Enter key using Javascript

If you want to disable ENTER key for any reason, you can try following javascript in your page.

Try it in the TextBox and Button by pressing ENTER key.

<script type="text/javascript">
document.onkeypress=function(e){
                        e=e?e:window.event;
                        if (e.keyCode==13)return false;
                    };
</script>

    

3 Responses to "Disable Enter key using Javascript"

Leave a Reply