Why does the onsubmit work on Firefox but not IE

Discussion in 'JavaScript' started by edolison, May 21, 2011.

  1. #1
    I am using this code for an HTML form and I am using Javascript to do form validation:

    <form name = "Reginfo" method="post" action="/cdcsreg/procdata.php" onSubmit = "return verify_data();">

    In the "verify_data" script it processes the instructions when I use Firefox and the processing stops, like it should. However, when I use IE the processing continues to "procdata.php".

    What could be wrong?
     
    edolison, May 21, 2011 IP
  2. shofstetter

    shofstetter Well-Known Member

    Messages:
    178
    Likes Received:
    7
    Best Answers:
    1
    Trophy Points:
    120
    #2
    IE sux :p You can cheat a little, and use a plain button, instead of a submit button. and call the javascript using the onclick method.

    in your function you could then add code to either submit the for or display and error message like this:

    if( code to check if form is valid){
    document.getElementByName("RegInfo").submit();
    }else{
    alert("you didn't do something right");
    }
     
    shofstetter, May 22, 2011 IP
  3. Sefrez

    Sefrez Peon

    Messages:
    26
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I totally agree. I don't really try to even support it anymore when creating scripts. IE 9, though, is MUCH better.
     
    Sefrez, May 22, 2011 IP
  4. Voynex

    Voynex Peon

    Messages:
    31
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I think the problem is in the code of the verify_data(). Possibly it return true somehow in IE and it sends the form to the server.
     
    Voynex, May 24, 2011 IP