I'm using the jQuery Validation Plugin (http://jqueryvalidation.org/) for a form that I've created. I have a file upload input field and I'm wanting to use the validation plugin to test a file's size before the form is sent so that if the file size is greater the 2MB then the form will not send and instead output an error message letting the user know that they need to use a smaller file size.
HTML
<form id="order-form" enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF'];?>" method="post" >
<input type="file" name="uploaded_file" id="uploaded_file" />
</form>
jQuery
$("#order-form").validate({
rules: {
uploaded_file: {
(check/validate file size code here)
}
},
messages: {
upload_file: "*Your file size is too large"
}
});