Skip to content

Instantly share code, notes, and snippets.

@maxcal
Created June 28, 2012 08:56
Show Gist options
  • Select an option

  • Save maxcal/3010007 to your computer and use it in GitHub Desktop.

Select an option

Save maxcal/3010007 to your computer and use it in GitHub Desktop.
jQuery Validate file upload
// assume that form is bound to $form and file input is named image
// @requires: jQuery, jQuery validate
// an array of valid file types
var whitelist = ['png','jpe?g','gif'];
$form.validate(
rules : {
image : {
accept: whitelist.join('|');
}
},
message : {
image: {
accept: "Please upload a valid file type."
}
}
);
@bhojkamal
Copy link
Copy Markdown

how to check the size of uploaded file max size 2mb required pls

@maxcal
Copy link
Copy Markdown
Author

maxcal commented Feb 20, 2021

@bhojkamal I doubt it has a built in file size validation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment