first commit
This commit is contained in:
22
plugins/jquery-validation/additional/maxsizetotal.js
vendored
Normal file
22
plugins/jquery-validation/additional/maxsizetotal.js
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
// Limit the size of all files in a FileList.
|
||||
$.validator.addMethod( "maxsizetotal", function( value, element, param ) {
|
||||
if ( this.optional( element ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( $( element ).attr( "type" ) === "file" ) {
|
||||
if ( element.files && element.files.length ) {
|
||||
var totalSize = 0;
|
||||
|
||||
for ( var i = 0; i < element.files.length; i++ ) {
|
||||
totalSize += element.files[ i ].size;
|
||||
if ( totalSize > param ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}, $.validator.format( "Total size of all files must not exceed {0} bytes." ) );
|
||||
|
||||
Reference in New Issue
Block a user