Created
June 28, 2012 08:56
-
-
Save maxcal/3010007 to your computer and use it in GitHub Desktop.
jQuery Validate file upload
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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." | |
| } | |
| } | |
| ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
how to check the size of uploaded file max size 2mb required pls