Welcome Guest, Not a member yet? Register   Sign In
Issue relate drop down list validation
#1

[eluser]123XD[/eluser]
Hi all,

I just had a question about drop down list validation.

I have some code like this in the view file

Code:
<select name="model">
  <option value=""></option>  &lt;!-- First value here is empty, used for validation --&gt;
  <option value="AAA">AAA</option>
  <option value="BBB">BBB</option>
  <option value="CCC">CCC</option>
</select>

and in related controller, I got

Code:
$rules['model'] = "required";
$this->validation->set_rules($rules);
$this->validation->set_message('rule', 'Error Message');


While I test this on localhost, it does not give me the error message.
I wanna drop down list to be mandatory. which means if the first option value is selected(in this case is blank), it gives user a error message.

I have read the user guide about validation class, but still cannot figure it out.
Does anyone has any ideas about this?

Thanks
#2

[eluser]CI Auke[/eluser]
What if you strip the value atribute.
a.i.
<option></option> &lt;!-- First value here is empty, used for validation --&gt;
#3

[eluser]123XD[/eluser]
woo```

That's cool, fixed```

forgot to try this one```

Thanks mate. Smile




Theme © iAndrew 2016 - Forum software by © MyBB