[eluser]Glowball[/eluser]
I'm successfully using the validation class with text and textarea fields, but I can't get it to validate a <select> field. How do I do this? In this example, the menu is of all of the states and the values are all two-digit codes. I want to make it required and two digits only.
Controller Snippet
Code:
$rules['state_abbr'] = "exact_length[2]";
$this->validation->set_rules($rules);
View Snippet
Code:
<select name="state_abbr" size="1">
<option value="">Select a State</option>
<?php while (list($state_abbr, $state) = each($states)):?>
<option value="<?=$state_abbr;?>" <?=$this->validation->set_select('state_abbr', $state_abbr);?> ><?=$state;?></option>
<?php endwhile;?>
</select>
It's in a form with other text fields and they are getting validated. This one select field is getting skipped. What's the trick? Thanks!