CodeIgniter Forums

Full Version: checkbox validation help needed
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]Computerzworld[/eluser]
Hello. I am having 7 checkboxes with 7 different names. I want that atleast one checkbox should be checked using CI validation. How can I do it? Plz help me. Thanks in advance.

El Forum

[eluser]MASS MASS[/eluser]
you do like this.......

<input type="checkbox" name="chked[]" value = "1">
<input type="checkbox" name="chked[]" value = "2">

in validation

$rules['chked'] = "required"

and

$field['chked'] = "Check field"

El Forum

[eluser]Dan Murfitt[/eluser]
Thanks for posting this, it seems to work well. How would you reference the default value with this? For example:

Code:
echo $this->validation->set_checkbox('chked[]', '1')

Thanks for your help.
Dan

El Forum

[eluser]Dan Murfitt[/eluser]
[quote author="Dan Murfitt" date="1218742890"]Thanks for posting this, it seems to work well. How would you reference the default value with this? For example:

Code:
echo $this->validation->set_checkbox('chked[]', '1')

Thanks for your help.
Dan[/quote]

Just found a thread with a working solution to this...
http://ellislab.com/forums/viewthread/73012/
Thanks