EasyUI Forum
May 03, 2024, 04:29:25 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: validate rule: 'remote'  (Read 38575 times)
varonica
Full Member
***
Posts: 106


View Profile
« on: December 26, 2012, 01:27:40 AM »

Hi sir, im trying to do as following code:
Code:
<input class="easyui-combobox" validType="remote['get_data.php','paramName']" />

Code:
//get_data.php
<?php 
$param intval($_REQUEST['paramName']);
if($param 10){
echo 'true';
}else{
echo 'false';
}


?>

No luck, it works perfectly but every time we click or writing one word in the textbox, it sends request out. Can it send a request after users finish writing or ".focusout()" Huh  Huh Huh
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: December 26, 2012, 06:59:23 PM »

To validate when inputs lose focus, try the code below.
Code:
$(function(){
$('#nn').bind('focus',function(){
$(this).data('validatebox').validating = false;
}).bind('blur',function(){
$(this).validatebox('validate');
});
});

Another way is to delay validating from the last inputting value, this feature will be supported in next version(1.3.2). This plugin can be downloaded from http://www.jeasyui.com/easyui/plugins/jquery.validatebox.js. To use the delay validating, assign the validatebox with a delay value.

Code:
<input class="easyui-combobox" delay="500" validType="remote['get_data.php','paramName']" />
Logged
varonica
Full Member
***
Posts: 106


View Profile
« Reply #2 on: December 27, 2012, 12:29:44 AM »

Code:
$(function(){
$('#nn').bind('focus',function(){
$(this).data('validatebox').validating = false;
}).bind('blur',function(){
$(this).validatebox('validate');
});
});
Hi sir, the above code seem not working correctly without putting "required" property. And here is what i messed up so far and hope u don't mind:
Code:
$.extend($.fn.validatebox.defaults.rules, {  
    check: { 
validator: function(value,param){ 
    var obj = $(param[0]).combobox('getData');
    var arr = [];
    arr = $.map(obj,function(n,i){
        var n = n.name1 || n.name2 ;
        return n;
    });
    var result = jQuery.inArray(value, arr);
    if(result == -1) return false;
    else return true;
          }, 
             message: 'Incorrect!' 
       } 
});
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #3 on: December 27, 2012, 02:17:10 AM »

Please refer to this example http://jsfiddle.net/AmEt6/.
Logged
varonica
Full Member
***
Posts: 106


View Profile
« Reply #4 on: December 28, 2012, 01:21:06 AM »

Hi sir, here is what i was trying: http://jsfiddle.net/p9LdJ/ . I just want to validate a combobox using .focusout() event( Everytime we focusout then let it validate the combobox )
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #5 on: December 28, 2012, 01:39:47 AM »

The alternate solution is to set a big delay value to prevent from validating when get focus. Please refer to updated example http://jsfiddle.net/p9LdJ/1/. To apply the 'delay' property on validatebox, please download the updated validatebox plugin from http://www.jeasyui.com/easyui/plugins/jquery.validatebox.js. This property will be supported since version 1.3.2.
Logged
varonica
Full Member
***
Posts: 106


View Profile
« Reply #6 on: December 28, 2012, 03:32:42 AM »

Thank sir for helping me!! Smiley Smiley Wink
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!