EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: phunksta on November 18, 2015, 07:03:14 AM



Title: validatebox return message from remote validator
Post by: phunksta on November 18, 2015, 07:03:14 AM
The 'remote' validation is defined as:
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 == 'true';
},
message: 'Please fix this field.'
}
})
It requires the server to return the 'true' string with no "\n" character.


Regarding the above where 'validator' is defined for a validatebox, is it possible to compose a message during the validator function and have this appear in the box's tooltip?


Title: Re: validatebox return message from remote validator
Post by: jarry on November 18, 2015, 06:49:07 PM
You can change the displaying message in the 'validator' function. Please refer to
Code:
validator: function(value,param){
var opts = $(this).validatebox('options');
opts.rules['remote']['message'] = ...;
...
},


Title: Re: validatebox return message from remote validator
Post by: phunksta on November 20, 2015, 04:27:46 AM
Many thanks - exactly what I was looking for!