EasyUI Forum
May 03, 2024, 05:10:21 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 return message from remote validator  (Read 6946 times)
phunksta
Jr. Member
**
Posts: 54


View Profile Email
« 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?
Logged
jarry
Administrator
Hero Member
*****
Posts: 2262


View Profile Email
« Reply #1 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'] = ...;
...
},
Logged
phunksta
Jr. Member
**
Posts: 54


View Profile Email
« Reply #2 on: November 20, 2015, 04:27:46 AM »

Many thanks - exactly what I was looking for!
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!