Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.8k
Closed
Labels
Description
This is a mix between jquery-validation and Modernizr, although we can port the Modernizr part out so Modernizr is not a dependency.
I'm wondering if you are open to having me add it to additional-plugins? It is a great feature :)
// Validate file input on changejQuery.validator.addMethod("filesize",function(value,element,param){// This requires Modernizr filereader community add-on:// <https://github.com/Modernizr/Modernizr/blob/master/feature-detects/file-api.js>varvalid=true;if(Modernizr.filereader){// Check if file size is valid// (e.g. value = "10485760" = 10mb)for(vari=0;i<element.files.length;i+=1){if(element.files[i].size>param)valid=false;}}returnthis.optional(element)||valid;},"File exceeds maximum upload size.");