Welcome Guest, Not a member yet? Register   Sign In
form validation and checking for allowed values for example in listbox
#3

[eluser]seba22[/eluser]
[quote author="CroNiX" date="1354387994"]You can only pass strings via the 2nd parameter, so you need to do something like:
Code:
$this->form_validation->set_rules('admin_title', 'Somefield', 'required|valid_array_element[' . implode(';', $array) . ']');

And then in your validation function, first line:
Code:
function valid_array_element($str, $allowed)
{
  $allowed = explode(';', $allowed);
  //..rest of your code
}
[/quote]


Thank You for reply.
It's working quite well.


What about displaying error ?

Drop down is a bad example, but i would like have error showing
You entered wrong value, allowed are a,aa,aaa

I was trying out to figure this by myself but i don't know...

I was trying to look at language file, for example here

Code:
$lang['min_length']   = "The %s field must be at least %s characters in length.";

But how pass them separated via coma values Wink

Regards


Messages In This Thread
form validation and checking for allowed values for example in listbox - by El Forum - 12-01-2012, 01:03 PM



Theme © iAndrew 2016 - Forum software by © MyBB