Welcome Guest, Not a member yet? Register   Sign In
form validation for conditional forms
#1

[eluser]umefarooq[/eluser]
Hi i have a question regarding CI form validation is it possible or not i have a survey form on any form where some form fields will be enable on some condition and i want to validate these fields if it is not enables then it should not be validate and submit form , example a survey question

Q. Do you like Codeigniter?

Options Yes or No radio button when user click on yes button text field will be enable or appear user have to fill it because it is a required field, if user click on NO then nothing will happen and user can submit form no validation for hidden or disable field and validation if enabled or appear.

any source, help or experience please share
#2

[eluser]umefarooq[/eluser]
anybody on CI community who can answer this question.
#3

[eluser]eoinmcg[/eluser]
can't you just do something like this in your controller?

Code:
$likes_ci = ($this->input->post('likes_ci') == 'on') ? 1 : 0;

if ( $this->input->post('likes_ci') == 'on' )
{
  //add in rules for this
  $this->form_validation->set_rules('extra1', 'Extra1', 'required');
}

// other validation rules goes here
  $this->form_validation->set_rules('name', 'Nmame', 'required');




Theme © iAndrew 2016 - Forum software by © MyBB