jQuery Validation Engine with Mime
- by Diego Pucci
I have this custom rule with tje jQuery validation Engine:
"validateMIME": {
"func": function(field, rules, i, options){
var fileInput = field[0].files[0];
var MimeFilter = new RegExp(rules[3],'i');
if (fileInput) {
return MimeFilter.test(fileInput.type);
} else { return true;}
},
"alertText": "* Estensione non supportata"
},
The problem is that this is working ONLY if the field is required. But in my case the field is not required, but if filled then the Mime type needs to be checked.
How do I edit this function to work with non required fields? what's wrong with it?
Thanks