treehouse : what would you like to learn today?
Web Design Web Development iOS Development

[Solved] onSubmit Validation is affecting multiple buttons - How to Stop?

  • Hi all,

    I have a form that onSubmit it validates the address. My problem is that it is also affecting my back button so when one hits back it tries to validate the form. Can I just have the back button go back without validating the form? Example below.

    <form action="##Form1URL##" name=msswe method=post onsubmit="return formBillValidate();">

    <--Code taken out because of length-->

    <input type="image" onclick="show_prompt()" name="Submit" id="checkout" style="float:right; margin-top: 10px;" src="/set-dur/images/continue_to_checkout.png" alt="Checkout" />

    <a href="http://www.duracoinc-test.com/mss-lx/mss-shop.nsf/WebEngine?OpenAgent "><input type="image" src="/set-dur/images/back.png" alt="back" style="float:right; margin: 10px 10px 0px 0px;" /></a>

    </div>
    </form>
  • I remember running into this problem awhile back. It seemed the issue was that any input that was type="image" was always treated as a submit button (or something similar).

    I'm not sure the code you have in place around it - but you could remove the input on the back button and style the href with css instead.
  • Thanks! That worked.