EducateYourself EducateYourself -4 years ago 148
PHP Question

Codeigniter form validation - at least one field is required

I have a submit form with 3 fields. At least one of the field should be filled in before submitting. Could you please help me to do it with codeigniter form validation.


$this->form_validation->set_rules('country', 'Country','trim|strip_tags');

Answer Source

Not a guru, but that will be my approach...

function do_add()
   if( (isset($_POST['country']) || (isset($_POST['state']) || (isset($_POST['city']) )
      //Do stuff
      //Redirect or whatever
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download