EasyUI Forum
October 18, 2025, 06:42:38 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: create validation when check box is check  (Read 13214 times)
john17
Newbie
*
Posts: 17


View Profile Email
« on: July 13, 2014, 11:37:34 PM »

hi guys,

is it possible to create a validation on validatebox when check box is checked?if yes how?

thanks
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: July 14, 2014, 02:27:20 AM »

To validate a checkbox field, you have to extend a new validate rule and apply it to this field.
Code:
$.extend($.fn.validatebox.defaults.rules,{
checked: {
validator:function(value,param){
var c = $(param[0]);
if (!c[0]._binded){
c[0]._binded = true;
c.unbind('.cc').bind('change.cc',function(){
c.validatebox('validate');
})
}
return c.is(':checked');
},
message:'Please check it.'
}
})

Apply this 'checked' rule to an existing field.
Code:
<input id="cc" type="checkbox" name="n1" class="easyui-validatebox" 
data-options="required:true,validType:'checked[\'#cc\']'">
Logged
john17
Newbie
*
Posts: 17


View Profile Email
« Reply #2 on: July 15, 2014, 01:21:44 AM »

thank you very much for your reply  Grin
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!