Welcome Guest, Not a member yet? Register   Sign In
Form Validation - problem with some chars
#1

[eluser]Unknown[/eluser]
Hi everyone!

I have a problem with some polish chars.

Model fragment:
Code:
...
$name = strtolower($this->input->post('name'));
$surname = strtolower($this->input->post('surname'));
..

Controller fragment:
Code:
$this->form_validation->set_rules('name', '"Imię"', 'trim|required|min_length[3]|alpha');
$this->form_validation->set_rules('surname', '"Nazwisko"', 'trim|required|min_length[3]|alpha');

View fragment:
Code:
echo form_label('Imię', 'name');
echo form_input('name').form_error('name');
    
echo form_label('Nazwisko', 'surname');
echo form_input('surname').form_error('surname');

I set a rule only aplha chars, so then I type character like ł, ą, ę it doesn't pass the validation.

Of course in my database I have set 'ut8_general_ci' and in config database file.
#2

[eluser]SPeed_FANat1c[/eluser]
You probably will have to extend form validation class, alpha rule, now it is:\

Code:
function alpha($str)
{
  return ( ! preg_match("/^([a-z])+$/i", $str)) ? FALSE : TRUE;
}

So thats why it is not valid I think.

Or create your custom validation rule.
#3

[eluser]Unknown[/eluser]
[quote author="SPeed_FANat1c" date="1337687398"]You probably will have to extend form validation class, alpha rule, now it is:\

Code:
function alpha($str)
{
  return ( ! preg_match("/^([a-z])+$/i", $str)) ? FALSE : TRUE;
}

So thats why it is not valid I think.

Or create your custom validation rule.[/quote]

Thanks. Smile I created my own rule.




Theme © iAndrew 2016 - Forum software by © MyBB