In the view file, you can perform client-side validation using the following command:
echo "<p>Salutation: "; $salutationOptions = array( '' => '', 'Dr' => 'Dr', 'Mr' => 'Mr', 'Ms' => 'Ms', 'Mdm' => 'Mdm', ); echo form_dropdown('salutation', $salutationOptions, '', 'required="required"'); echo "</p>";
When a user tries to send without selecting the form of the drop-down list, he will give them an error saying that they should choose from the drop-down list.
If you want it on the server side, you can do something like this:
$this->form_validation->set_rules('salutation', 'Salutation', 'required') if($this->form_validation->run()){ }else{ }
source share