1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2001
    Rep Power

    Javascript Key Locking

    Is it possible to lock the return key on a form, so it cant be pressed, and the form submitted.
  2. #2
  3. No Profile Picture
    The one who gets it done
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2001
    Madison, WI
    Rep Power
    Sure. disable it. Something like: document.FORMNAME.BUTTONNAME.disabled=true;

    Idea 2: Change the button so that instead of being type=submit, onclick="submitFunction();", or some such. In that function use whatever testing to decide if it will submit the form: document.FORMNAME.submit();


  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2001
    Rep Power
    You should be able to.

    I would think all you would need to do is trap all keyboard activity and allow any trapped key except return carry on as normal while sinking a return keypress to a false return.

    I know this can be done on text fields and form elements I am not 100% sure about the forms themselves but dont see why not.

    Even if you cant do it on the whole form itself you can do it on each form element. Just on each element have the onKeyPress() event handler invoke a function that checks the keycode generated and filter out return keys (I THINK the return key code is 13, but again not 100% sure)

    I hope this gets you in the right direction if you need more I will gladly post more later when I have my resources in front of me.

    **Ive tried the disabled thing, didnt seem to work all the time across platforms, let me know if you try it and it does for you I will go back and see what I snafu'd **
    Last edited by admap; July 12th, 2001 at 09:45 AM.

IMN logo majestic logo threadwatch logo seochat tools logo