I have a requirement where I need to upload multiple files using Blueimp file upload. The other requirement I have is to submit some data from a set of fields (textboxes) which are required fields.
For example, users will pick a couple of files to upload and give a name, type, date, etc and these fields are mandatory. I should submit both the files and form data together.
To do this, I performed the validation of the form fields inside the submit callback of the file upload.
$('#fileupload).fileupload({
singleFileUploads: false,
autoUpload: false,
acceptFileTypes: /(jpg)|(jpeg)|(png)|(gif)|(pdf)|(doc)|(docx)$/i,
submit:
{
if(formValid())
{
return true;
}
else
{
return false;
}
}
});
This works great if users didn't enter the mandatory fields the first time and its shows the validation errors.
Problem is if the users correct the form after we cancelled the submit and click save, submit is not getting fired unless users select another file and hit save again.
<button type="button" class="btn btn-primary start">
<i class="icon-upload icon-white"></i>
<span>Save</span>
</button>
Any ideas how I could handle this. I am ok with handling the submit in code but I am not sure how to access the "files" data in javascript code.