Disable enter key in a form

Posted on 2006-04-26
Last Modified: 2013-12-18
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.
Question by:ninteen83

    Author Comment

    Internet explorer displays "Form processed"message ..
    LVL 19

    Accepted Solution

    //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.

    Author Comment

    Works fine..


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    This is an old article, please see an updated version of this article, located here:
    Notes Document Link used by IBM Notes is a link file which aids in the sharing of links to documents in email and webpages. The posts describe the importance and steps to create a Lotus Notes NDL file in brief.
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now