Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Aug 2005
    Location
    Toronto, ON, Canada
    Posts
    231
    Thanks
    0
    Thanked 0 Times in 0 Posts

    (IE) Stopping propagation of ESC keydown event in form AFTER the active field reset

    On an ESC keydown event, the IE resets entire form. I am looking for solution where ESC resets ONLY the active input field of the form.

    Code:
    if (document.all)
      document.onkeydown = function () {
        return event.keyCode != 27;
      }
    prevents ALL resets, that is not what I am looking for.

    tnx,
    rm -f

  • #2
    Regular Coder
    Join Date
    Jan 2004
    Posts
    185
    Thanks
    2
    Thanked 1 Time in 1 Post
    would this not work?
    Code:
    document.onkeydown = function () {
    	if(event.keyCode==27) {
    	event.srcElement.value = '';
        return false;}}

  • #3
    Regular Coder
    Join Date
    Aug 2005
    Location
    Toronto, ON, Canada
    Posts
    231
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    event.srcElement.value = '';
    sets value to nothing not to previous value.

    Lets say the original value was:
    ABCD
    the value has been changed to:
    ABCDefgh
    after ESC has been pressed the value should be:
    ABCD

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    You can get the original value of a textbox by accessing the defaultValue attribute.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________


  •  

    Posting Permissions

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