Sashidhar Kokku's blog

How To : Disable Enter key in web forms

Include the following code in the <head> tag, or in the common.js file in your website(hoping that you call it in the master page or the relevant form).

function disableEnterKey()
{
  if (window.event.keyCode == 13) window.event.keyCode = 0;
}

And in the form that you want to disable the Enter/Return key, add the following code.

  <form id="form1" runat="server" onkeypress="disableEnterKey()" >

Its completely situation dependent, but I use it at the master-page level itself.

Leave a Comment

(required) 

(required) 

(optional)

(required)