Welcome Guest, Not a member yet? Register   Sign In
checkbox form vaildation (sort of)
#1

[eluser]pendalpusher[/eluser]
I have two issues, that seem to be form validation issues, but I'm not sure how to work them in. let me explain each in some detail.

1. I have two checkboxes on the form One or Both of them can be checked, but it is required that at least one be checked.

right now I have them like this
Code:
//....more code

<?=form_checkbox('press[]','press_1');?>Machine 1
<br />
&lt;?=form_checkbox('press[]','press_2';?&gt;Machine 2

//... more code

how would i leverage the form validation class to check if one or both of these are checked?


the second problem is similar but involved a check box and a text field.
if the checkbox is set, then the text field is required.
Code:
//.... more code

&lt;?=form_checkbox('other','other');?&gt;Other (details required)
<br />
&lt;?=form_input('other_details','Other Details');?&gt;

//...more code

again .. how would I use the form validation class to check this?


I started writing a MY_Form_Validation class, but I don't know how to invoke it on the form fields once they are written.

Thanks in advance for any help.




Theme © iAndrew 2016 - Forum software by © MyBB