EasyUI Forum
April 18, 2021, 02:46:36 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: validatebox.rules.remote  (Read 82 times)
Coder
Jr. Member
**
Posts: 72


View Profile
« on: April 07, 2021, 11:01:49 AM »

Please change

Code:
var _580=$.ajax({url:_57f[0],dataType:"json",data:data,async:false,cache:false,type:"post"}).responseText;
return _580=="true";
to

Code:
var _580=$.ajax({url:_57f[0],dataType:"json",data:data,async:false,cache:false,type:"post"}).responseText;
return _580.replace(/\s/g, '')=="true";

some API return true/false + LN

thnx!
Logged
jarry
Administrator
Hero Member
*****
Posts: 1972


View Profile Email
« Reply #1 on: April 07, 2021, 07:44:13 PM »

You can override this validate rule according to your own data format from server.
Code:
$.extend($.fn.validatebox.defaults.rules, {
remote: {
validator: function(value, param){
var data = {};
data[param[1]] = value;
var response = $.ajax({
url:param[0],
dataType:'json',
data:data,
async:false,
cache:false,
type:'post'
}).responseText;
return response.replace(/\s/g, '') == 'true';
},
message: 'Please fix this field.'
}
})
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!