Form Reset Button Confirmation

Discussion in 'JavaScript' started by jestep, Feb 24, 2006.

  1. #1
    I would like to have a confirmation warning if someone presses the reset button on a form on my site. I have seen it done, but I don't know how to do it.

    Basically, user presses reset button. Alert or Warning popup appears and asks if they are sure they want to clear the form. They select yes or no, and the appropriate action occurs.
     
    jestep, Feb 24, 2006 IP
  2. mad4

    mad4 Peon

    Messages:
    6,986
    Likes Received:
    493
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Personally I don't ever use the reset button and stopped adding it to my sites a few years ago after people complained.

    You are right to try and implement a solution so people don't click it by accident but maybe you would be better removing it altogether?
     
    mad4, Feb 24, 2006 IP
  3. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #3
    After thinking about it, I think you're totally right. I don't even know why I still had the reset button on there. I think that it has been on there so long, that I never thought about removing it. Who every uses a reset button anyways when checking out out of a website.
     
    jestep, Feb 24, 2006 IP
  4. Ilija Studen

    Ilija Studen Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I don't know if you still want need it but code is pretty simple:

    <form onreset="return confirm('Are you sure?')">
      <input type="text" value="Inital value" />
      <button type="reset">Do reset</button>
    </form>
    Code (markup):
     
    Ilija Studen, Feb 25, 2006 IP