ShaggyInjun
ShaggyInjun

Reputation: 2963

submit button submits wrong form

I have two forms, a login form and a register form on the same page and each has its own submit button. If I fill in bad data and click on submit button on register form, I get the form back with errors ( expected). If I now enter sign in details on signin form and click on signin form's submit button, the register form gets submitted.

This is strange behaviour. I am not sure where to start search for this. I am using firefox to test this.

Thanks

Upvotes: 1

Views: 4572

Answers (1)

Mohammed Joraid
Mohammed Joraid

Reputation: 6480

Well, you will need to debug it step by step.

  • Check your form nesting and follow good structure, make sure both form are not overlapping with each other or not being closed properly.
  • Give you form a proper ID and NAME. Be careful when two forms have the same name From Name Attr.
  • Based on your structure and your question, make sure you have a different submit buttons for each form and that button is placed within the form nesting.
  • Same as for the forms, give your submit button a proper unique ID and NAME .
  • Choose whether you want to submit by your using submit in html, or having JS to submit the form for you JS submit form.
  • If you are using HTML5, you can separate the button from the FORM. They can run separately. Means dynamic association between the form and it's submit button by having submit button placed anywhere and can submit a form located in different place. Check Association of Controls and Forms & HTML5′s New “form” Attribute.

Please post some code in order for us to have a better understanding of your issue. Good luck.

Upvotes: 4

Related Questions