I wrote the following rule for my file field, as I wish to only accept Word Documents of PDF files.
paperupload:{required: true, accept: "application/msword, application/pdf"}
When I tested with uploaded a JPG file, the form submits without validating the other fields as well. Is there something wrong I've done here?
$("#papersubmitform").validate(
{
submitHandler: function(form) {
$(form).submit();
},
messages: {
//CHECK Correspondence Authors' Information
contactTitle: "Please specify Correspondence Author's Title",
contactFirstName: "Please specify Correspondence Author's First Name",
contactLastName: "Please specify Correspondence Author's Last Name",
contactEmail: "Please specify Correspondence Author's Email Address",
contactUniList: "Please specify Correspondence Author's University",
//paperTitle:"Please specify Paper Title",
paperAbstract:"Please specify Paper Abstract"
},
rules:{
//Rules for Correspondence Author's Information
contactTitle: {required: true},
contactFirstName: { required:true},
contactLastName: { required:true},
contactEmail: {required:true, email: true},
contactUniList:{ required:function(){
if(checkuninotinlist){ return false; }
else { return true; }
}
},
contactUniversityName:{ required: function(){
if(checkuninotinlist){ return true; }
else { return false; }
}
},
contactUniCountry:{ required: function(){
if(checkuninotinlist){ return true; }
else { return false; }
}
},
contactOrganisation: { required:function(){
if(checkorganisation){ return true; }
else { return false; }
}
},
contactOrgCountry: { required:function(){
if(checkorganisation){ return true; }
else { return false; }
}
},
mailinglist:{required:true},
researchmethod:{required:true},
//PAPER INFORMATION
paperTitle:{required:true},
paperAbstract:{required:true},
paperupload:{required: true, accept: "application/msword, application/pdf"}
}
});
HTML HERE
<input type="file" name="paperupload" />