jquery - Upload files using Blueimp file upload only if condition is true -


i have requirement need upload multiple files using blueimp file upload. other requirement have submit data set of fields (textboxes) required fields.

for example, users pick couple of files upload , give name, type, date, etc , these fields mandatory. should submit both files , form data together.

to this, performed validation of form fields inside submit callback of 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 mandatory fields first time , shows validation errors.

problem if users correct form after cancelled submit , click save, submit not getting fired unless users select file , 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 handle this. ok handling submit in code not sure how access "files" data in javascript code.

can't call formvalid() click event of save button?

$("#save").on("click",function(){     if(formvalid()) {         $('#fileupload).fileupload({         //your stuff         })     } }) 

Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -