I have a weird problem.I have a form with a file upload and few other textarea .each and every field is required.so basically when few fields are left blank,the validation w
Your code appears to be working just fine. Hidden fields are ignored by the Validate plugin. However, when you show the file upload field via radio button, it will validate and display the error message. See: http://jsfiddle.net/y5ghU/
Your code:
<input type="file" name="fupl" style="display:none;margin-top:10px" id="fup"/>
Your file upload field is set to display:none;
and the plugin will ignore all hidden fields by default.
Use the ignore: []
option to disable this feature.
$(document).ready(function () {
$('#form').validate({
ignore: [],
rules: {
fupl: {
required: true,
accept: 'docx|doc'
}
}
});
});
DEMO: http://jsfiddle.net/ptV35/
EDIT: Not really sure which way the OP wants to go, but the following demo hides any pending error message when the file upload field is re-hidden.
$("#fup").next('label.error').hide();
http://jsfiddle.net/y5ghU/4/