$(document).ready(function() {
$("#basicprofile").validate({
rules: {
profilePic: {
required: true,
accept: "gif|png|jpg|jpeg|pjpeg"
}
},
messages: {
profilePic: {
required: "Empty file",
accept: "Wrong format!!"
}
},
errorPlacement: function(error, element) {
$("#error-messages").html(error); // error container
}
});
});
You can check that the field is Filled and file have correct format in browser, but check filessize is hard problem. You have to do it with AJAX, and use the filesize headers sent by the browser to the server on the POST request.
Yahoo's UI Library has a tool to help with this. YUI Uploader
Example (without check file size): http://jsfiddle.net/burlak/U36JS/