Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Disable Enter key submit from within text field (again...)

Avatar of Rouchie
RouchieFlag for United Kingdom of Great Britain and Northern Ireland asked on
JavaScript
7 Comments1 Solution1665 ViewsLast Modified:
I've seen thousands of variations to this question but the only solutions that fit seem to be IE only, so here goes...

I need some javascript that I can add to a text input field that stops the form submitting when Enter is pressed.  As I'm using ASP.NET however, there are some additional requirements:

 1. I have no need to perform validation in the form (this is handled server-side by ASP.NET)
 2. I would prefer not to have to edit the <form> tag as this is inside a template.  If the code can affect only the desired text field that would be superb
 3. The solution really just needs to be a cross-browser compatible version of this:
           onkeypress="return !(window.event && window.event.keyCode == 13); }"
ASKER CERTIFIED SOLUTION
Avatar of Zvonko
ZvonkoFlag of North Macedonia imageSystems architect
Commented:
This problem has been solved!
Unlock 1 Answer and 7 Comments.
See Answers