EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: Coder on April 07, 2021, 11:01:49 AM



Title: validatebox.rules.remote
Post by: Coder 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!


Title: Re: validatebox.rules.remote
Post by: jarry 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.'
}
})


Title: Re: validatebox.rules.remote
Post by: Coder on April 19, 2021, 12:28:04 PM
thnx

// why this code not to implement to source of easyui?