Search code examples
javascripthtmldom-eventsmultipartform-data

Form submission not posting data after previous preventDefault'd events


I have a form which, when submitted, is first validated by a function that is bound to the form's "submit" event. If the validation fails, the submit event has it's default action cancelled via e.preventDefault(). If the form submits correctly the first time, it works. If, however, it experiences a preventDefault then subsequent submissions do not send any form data in the POST request. I analyse this in the Chrome code inspector. FYI it is a multipart/form-data form.

Is there any reason that the form would ignore all the inputs when submitting?


Solution

  • I found my problem. Form elements that have the "disabled" attribute are not included in submission. I was disabling form elements in order to disallow the user from editing things while waiting for response from the server (it is an asynchronous post to an iframe).