Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 367
  • Last Modified:

Disable enter key in a form

a form has a field and a button. I'm doing some lookup on the button. When I type some values in the field and click on the button, It works fine. On Opera and Firefox, when I type some values in the field and press ENTER key, it works fine, returns the document.

But when I enter a text and press enter instead of pressing that button, browser displays "Form processed"message

Is there any way to disable enter key in the browser.
  • 2
1 Solution
ninteen83Author Commented:
Internet explorer displays "Form processed"message ..
//For fields which enters Enter Key from the field
var NS1 = (window.Event) ? 1 : 0;
function checkKey(e1) {
var code1 = (NS1) ? e1.which : event.keyCode;

if (code1 == "13"){
return false;

call this function where ever needed.
ninteen83Author Commented:
Works fine..


Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now