EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: rezzonico on March 03, 2020, 12:54:49 AM



Title: filebox + validType +onChange
Post by: rezzonico on March 03, 2020, 12:54:49 AM
Hi all,

I have a filebox where I test the filesize.

Here the code:

Code:
               {field:'uploadFile',title:'File',width:300,
                  editor: {
                     type: 'filebox',
                     options: {
                        validType: 'maxFileSize[10000]',
                         onChange: function(value) {
                           var File = value;
                           _uploadFile($(this), File);
                        }
                     }
                  }
               }

_uploadFile() is a function that upload the file to the server and starts after an onChange event.
This means that the file is uploaded also if the maxFileSize test is no passed.
How can I avoid this ?
In other words I want to start the function _uploadFile() only if the maxFileSize test is passed.

Thanks
Miche


Title: Re: filebox + validType +onChange
Post by: jarry on March 06, 2020, 01:28:36 AM
Please try this code.
Code:
type:'filebox',
options:{
validType:...,
onChange: function(value){
var fb = $(this);
var isValid = $(this).filebox('isValid');
if (isValid){
// ...
}
}
}


Title: Re: filebox + validType +onChange
Post by: rezzonico on March 06, 2020, 02:52:15 AM
Thanks a lot !

Regards
Miche