www.webdeveloper.com
Results 1 to 3 of 3

Thread: Disable Enter button

Hybrid View

  1. #1
    Join Date
    Nov 2012
    Posts
    1

    Disable Enter button

    I added some Javascript to a page on my website...
    http://tomorrowschampion.com/advocare-login/

    It is working fine, the problem is whenever someone types in their ID number and they press "Enter" it goes nowhere. They have to physically hit the "Submit" button. How can I disable the enter key in that specific page or link it to press the submit button?

  2. #2
    Join Date
    Jul 2007
    Posts
    386
    Your button is a "button". To make it submit when its clicked you need to change the type to submit.

    Code:
    <input type="submit"/>

  3. #3
    Join Date
    Sep 2011
    Location
    Bristol, England, United Kingdom
    Posts
    192
    Yes, make it a submit button. Just out of interest, if you did want to disable the enter key, you could do this:

    Code:
    <input id="password" type="text" name="password" size="20" onkeypress="return handleEnter(this, event)">
    
    function handleEnter(field, event)
    {
        if(event.keyCode == 13) // Enter has been pressed
        {
            event.stopPropagation();
            event.preventDefault();
            return false;
        }
    }
    However, I do not recommend doing this since the problem can be solved in 6 letters (submit).

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles