IE8 - FF3.5 Jquery form submit problem.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • aaronkmar
    New Member
    • Dec 2008
    • 38

    IE8 - FF3.5 Jquery form submit problem.

    Hello Bytes,

    I'm definitely a java newbie and have been working on an application recently and ran into strange behavior between browsers and wondered if anyone could help.

    I'm sure my code is going to make you pros cry, but I'm trying!

    I have an index php page located at


    (Text version)

    If you click Register in the upper right corner, the register div appears with the form.
    Fill in the form and click Register.
    This is where the difference occours.

    Unbelievably this works as intended in IE8 but not in FF, the registration form is submitted via post to signup.php (txt version).

    If the username already exists, it reports that accordingly.
    If it does not exist then insert into the db.

    In IE8 this is how it happens, but in FF it does this;

    Fill in form and submit.
    The form reports that the username already exists but it actually inserts the data correctly.

    When tailing the mysql log, the signup.php appears to run the query twice but I just don't understand why.

    I'm not used to something working in IE but not FF!

    If I can provide any other info please let me know and thank you in advance if you are willing to assist this noob.

    Regards,
    Aaron
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    What FF is doing is correct, though not what you want it to do. The form is being submitted twice because a button click is also a submit (the default). IE went against standards and decided it's a normal button.

    See http://www.w3schools.com/tags/tag_button.asp
    Always specify the type attribute for the button. The default type for Internet Explorer is "button", while in other browsers (and in the W3C specification) it is "submit".

    Comment

    • aaronkmar
      New Member
      • Dec 2008
      • 38

      #3
      Ooooooh I see.
      So by giving it a type 'button' that fixed it right up.
      Man I would have never figured that out.

      Figures IE doesn't conform to the standard, reminds me of their own version of IMAP.

      Thank you very much acoder.

      Now on to my next brain-buster. =P

      Respectfully,
      Aaron

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        Perhaps you should give it a type "submit" and remove the onsubmit code (which just calls submit() anyway).

        It's good habit not to rely on defaults anyway. Not all browsers have the same defaults, so it's better to specify exactly what you're after.

        Comment

        Working...