[eluser]Alhazred[/eluser]
I've read that there are 2 ways to use regex with form's fields validation
1) regex_match[...here the regex...]
2) using a callback
I've tried both the methods, but I don't get what I expect.
Code:
//validation
$this->form_validation->set_rules('name','lang:crd_form_name','required|callback_validate_names');
//callback function
function validate_names($string)
{
return preg_match("/^[a-zA-Z'\s]$/", $string);
}
I can't use "alpha" because it doesn't accept characters like ' and I want to allow them in the "name" field, or the poor Mr. O'Connor can't register himself on my website.
That let pass also strings like O'Connor$%£, it looks that the check is not executed.
What's my mistake?
P.S. Don't say that my mistake is that I want Mr. O'Connor to register on my website