CodeIgniter Forums
checkbox validation help needed - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forum-21.html)
+--- Thread: checkbox validation help needed (/thread-8076.html)



checkbox validation help needed - El Forum - 05-04-2008

[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.


checkbox validation help needed - El Forum - 05-05-2008

[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"


checkbox validation help needed - El Forum - 08-14-2008

[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


checkbox validation help needed - El Forum - 08-14-2008

[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