jQuery.validate file upload
Hello, I`m using the jQuery.validate plugin from
http://bassistance.de/ . I would like to add custom <input type="file" /> validation to my script.
- <script type="text/javascript">
$(document).ready(function () {
$("#name,#file").addClass("required");
$("#preventspam").addClass("required digits");
$("#email").addClass("required email");
$("#telefon").addClass("digits");
$("#contact").validate({
errorLabelContainer: $("#contact div.error")
});
return false;
});
</script>
And this custom method or any other method in fact that restricts file type beside docx,doc and pdf:
jQuery.validator.addMethod("accept", function(value, element, param) {
return value.match(new RegExp("." + param + "$"));
});
rules: {
fileupload: { accept: "(docx?|doc|pdf)" }
}
Any help is appreciated. Thanks.
Catalin