Welcome Guest, Not a member yet? Register   Sign In
Validation based on another field's value
#2

[eluser]CroNiX[/eluser]
I haven't set up my rules using a multidimensional array like you are, but I usually do something like:
Code:
//the field with the checkbox
$check1 = $this->input->post('field_with_checkbox');
$rules = '';
if($check1 !== FALSE && $check1 == '1')
{
  //if the checkbox was checked, add a required field to the rules for the other field
  $rules .= 'required|';
}
//append regular rules for the field
$rules .= 'trim|xss_clean';
//apply rules to the textbox field, "Explain"
$this->form_validation->set_rules('field', 'label', $rules);

That might not be exactly right, I can't check right now.


Messages In This Thread
Validation based on another field's value - by El Forum - 03-17-2011, 12:02 PM
Validation based on another field's value - by El Forum - 03-18-2011, 04:51 PM
Validation based on another field's value - by El Forum - 03-21-2011, 12:12 PM



Theme © iAndrew 2016 - Forum software by © MyBB