EasyUI Forum
May 11, 2024, 02:56:59 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: filebox + validType +onChange  (Read 3354 times)
rezzonico
Full Member
***
Posts: 183


View Profile
« 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
« Last Edit: March 03, 2020, 12:58:16 AM by rezzonico » Logged
jarry
Administrator
Hero Member
*****
Posts: 2264


View Profile Email
« Reply #1 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){
// ...
}
}
}
Logged
rezzonico
Full Member
***
Posts: 183


View Profile
« Reply #2 on: March 06, 2020, 02:52:15 AM »

Thanks a lot !

Regards
Miche
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!