You need two things.
(1) use valid syntax to use the accept
method, because it requires that you use mimetypes to provide comma-separated lists of types.
$(document).ready(function(){ $("#form").validate({ errorLabelContainer: "#message_box", wrapper: "li", rules: { image: {required: true, accept: "image/jpg,image/jpeg,image/png,image/gif"} }, messages: { image: {required: 'Required!', accept: 'Not an image!'} } }) });
(2) . You will need to enable additional-methods.js
because accept
methods are not included in the main validation plugin. So add the following to your <head>
after enabling validate plugin
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/additional-methods.min.js"></script>
Here's a link to jsfiddle . Note that it includes debug: true
to prevent the form from being published in the script.
Ejaz source share