Last active
December 21, 2015 16:59
-
-
Save dschnare/6337123 to your computer and use it in GitHub Desktop.
jQuery Validate File Fields Quirkiness - Example of how to manually update the valid state of a file field when using jQuery Validate.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// jQuery Validate setup. | |
$('form').validate({ | |
rules: { | |
"cover-letter": { | |
required: true, | |
accept: "application/pdf|application/msword|application/vnd.openxmlformats-officedocument.wordprocessingml.document" | |
} | |
}, | |
messages: { | |
"cover-letter": "Please upload your cover letter (PDF, DOC or DOCX)." | |
} | |
}); | |
// The fix for file fields not re-validating when they change. | |
$('#cover-letter').change(function () { $(this).valid(); }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment