EasyUI Forum
April 29, 2024, 07:58:29 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: numberbox remote Question  (Read 7490 times)
fen9ye
Newbie
*
Posts: 7


View Profile
« on: June 17, 2014, 02:19:14 AM »

My code is like this:
<input type="text" class="easyui-numberbox" name="candNum"
            data-options="
               min:0,
               max:99999,
               required:true,
               validType:{
                  length:[1,5],
                  remote:['info_validateCandNum.action','candNum']
               },
               delay:400,
               formatter:function(value){
                  var str = value.toString();
                  while(str.length<5){
                     str = '0'+str;
                  }
                  return str;
               }
            ">
the server side can get the param,and will return 'true' at last
 PrintWriter out = response.getWriter();
 out.println("true");
however,the numberbox is still in the invalid state.Can anyone solve my problem?
Logged
fen9ye
Newbie
*
Posts: 7


View Profile
« Reply #1 on: June 17, 2014, 02:21:39 AM »

When I turn out.println("true") to out.print("true"),it works,I don't know why.
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #2 on: June 17, 2014, 05:58:56 PM »

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.
Logged
Coder
Jr. Member
**
Posts: 96


View Profile
« Reply #3 on: October 02, 2020, 05:09:22 AM »

can be original fixed to:

Code:
}).responseText;
return response.replace(/\s/g, '') == 'true';

?
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!