setting up an application page-how do you restrict the enter key to be used similar to the tab key?

Posted on 2005-04-19
Last Modified: 2010-04-25
I was wondering how you would set this up, say if you had a ton of forms and you don't want people to be able to send the forms by simply pressing enter(by mistake thinking it will take them to the next form)-is this a viable question?- i'm not sure design wise if there is an elegant solution to this? what is your recomendation?
Question by:toddkeller
    LVL 20

    Accepted Solution

    Can be solved with a little javascript, this will disable the enter key... and force user to click submit

    <title>The Title Of Your Page Goes Here!</title>
    <script language="javascript" type="text/javascript">
    function checkCR(evt) {
    var evt = (evt) ? evt : ((event) ? event : null);
    var node = ( ? : ((evt.srcElement) ? evt.srcElement : null);
    if ((evt.keyCode == 13) && (node.type=="text")) {return false;}
    document.onkeypress = checkCR;

    <p><center><form action="" method="post">
    Email Address<br><input type="text" name="field1" size="40" /><br>
    Subject Matter<br><input type="text" name="field2" size="40" /><br>
    Enter Your Comments<br><textarea cols="40" rows="5" name="field3" wrap="physical"></textarea><br>
    <input type="submit" value="Send it!"><input type="reset" value="Clear it!">


    LVL 20

    Expert Comment

    Just a note, the javascript requires that there as at least one form type of text meaning you have to have one of these...

    <input type="text" name="yourFieldName" ... >

    hope that helps,
    LVL 1

    Author Comment

    That's awesome!, thanks a lot-i've got another question for you i'll post tonight that would be super helpful to me as well, thanks again,
    LVL 20

    Expert Comment

    Sure, not a problem! I'd be happy to answer any questions you have :o)

    Best Regards,
    LVL 20

    Expert Comment

    Thanks for the points :o)

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Join & Write a Comment

    Suggested Solutions

    For those who don't know, Adobe Dreamweaver is a popular commercial web editor that enables you to design, build and manage complex websites. The editor is a WYSIWYG (What You See Is What You Get) web editor, which means that you can create your web…
    I still run into .cgi files every now and then. In some instances, I actually prefer the simplicity of a .cgi script to other options. Since I use DreamWeaver extensively, what I needed was a way to open .cgi scripts in Dreamweaver. And I wanted to …
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    746 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

    15 Experts available now in Live!

    Get 1:1 Help Now