EllisLab text mark
Advanced Search
     
Form validator rule alpha and UTF-8
Posted: 09 November 2012 01:47 PM   [ Ignore ]
Avatar
Joined: 2012-05-24
19 posts

When I set the alpha validation rule for a input field in my form and when I type characters like ŠĐČĆŽ etc the rule doesn’t see those characters as letters. I use a database that has UTF-8 encoding. How do I modify the regex ( “/^([a-z])+$/i” ) to include those letters?

EDIT: I can do it with “/(*UTF8)^([a-zšđčćž])+$/i” . Is there a better solution?

 
Posted: 09 November 2012 03:49 PM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Avatar
Joined: 2012-01-09
117 posts

Create a callback rule, the already included ‘alpha’ rule is only supposed to work with latin characters (and next version will use ctype_alpha() instead of a regular expression).

 
Posted: 10 November 2012 03:51 AM   [ Ignore ]   [ # 2 ]   [ Rating: 0 ]
Avatar
Joined: 2012-05-24
19 posts
Narf - 09 November 2012 03:49 PM

Create a callback rule, the already included ‘alpha’ rule is only supposed to work with latin characters (and next version will use ctype_alpha() instead of a regular expression).

Thank you for answering. For now I just extended the Form_validation class (added MY_ prefix etc).

Btw can you give me a link where I can find future changes (like the one you just written about ctype_alpha() being used in the next version).

 
Posted: 10 November 2012 04:03 AM   [ Ignore ]   [ # 3 ]   [ Rating: 0 ]
Avatar
Joined: 2007-11-28
2435 posts

https://github.com/EllisLab/CodeIgniter

 
Posted: 11 November 2012 06:30 AM   [ Ignore ]   [ # 4 ]   [ Rating: 0 ]
Avatar
Joined: 2012-05-24
19 posts

Thanks.