Validate check box


I want to validate a check box but it doesn’t works for me. I tried to use compare, required and boolean validators. Which validator must be used and how?

This check box will be the ‘Agree the Terms and Conditions’. The message when isn’t ticked must be ‘You must agree the Terms and Conditions’.

[color="#006400"]/* Moved to proper forum */[/color]


This works for me:

// form

<?php echo $form->checkBox($signup, 'accept');?>

// model rules

array('accept', 'compare', 'compareValue' => 1, 'message' => 'You should accept term to use our service'),

Not sure that is best way. I think ‘require’ validator should work too

array('accept', 'required', 'requiredValue' => 1, 'message' => 'You should accept term to use our service')

"required" validator has "requiredValue" attribute, use it.

Hey can you tell same thing for multiple checkbox validation for any one checkbox is checked

Check This Link ! It Might Help You

I have Solved this problem by reload captcha after errors.

Here is my code:

Js function in custom.js file:

function reloadCaptcha() {


            url: "registration/captcha/refresh/1",

            dataType: "json",

            cache: false,

            success: function(data) {

                jQuery("#yw0").attr("src", data["url"]);

                jQuery("body").data("captcha.hash", [data["hash1"], data["hash2"]]);




//Captcha image which will auto generate 

<img id="yw0" alt="" src="">

//ajaxLink or ajaxSubmitButton

 echo CHtml::ajaxLink('Submit', 'registration', array(

                                    'type' => 'POST',

                                    'success' => 'js:function(data){

                                         var responce = jQuery.parseJSON(data);

                                        if (responce.success) {







                                        ), array(

                                    'id' => 'send-link-' . time(),