3

My form, 'file-upload' has a submit button:

<button id="btn-save" type="submit">Save</button>

I use it like so:

$('#file-upload').submit(this.save.bind(this));

The problem is, my form has other buttons in it:

<button class="btn-delete">&times;</button>

And these appear to be running the this.save method.

How can I prevent this?

panthro
  • 22,779
  • 66
  • 183
  • 324
  • possible duplicate of [what's the standard behavior when < button > tag click? will it submit the form?](http://stackoverflow.com/questions/4667979/whats-the-standard-behavior-when-button-tag-click-will-it-submit-the-form) – gustavodidomenico Jun 24 '14 at 13:53

1 Answers1

4

This is a know behavior, all <button> s inside the form tag would act like a submit button, you either need to prevent its default behavior by event.preventDefault() or change those buttons to <input type='button'>

Rajaprabhu Aravindasamy
  • 66,513
  • 17
  • 101
  • 130
  • You can also add type="button" to the button element: If you prefer not to change them to inputs. – laymanje Jun 24 '14 at 14:07