CodeIgniter Forums
Form validation with special characters like accents - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Form validation with special characters like accents (/showthread.php?tid=59428)



Form validation with special characters like accents - El Forum - 10-04-2013

[eluser]ckelly06[/eluser]
Hey guys,

I just spent the last half hour scouring Stackoverflow, this forum (which has this question posted several times but no solutions that worked for me) and Google but haven't had any luck. I simply need my form to accept accented characters like "é" when I use the alpha_dash validation function. I found one solution that said to do it this way:

Code:
$str = utf8_encode($str);
return ( ! preg_match("/^([\p{L}a-zA-Z0-9]*)$/i", $str)) ? FALSE : TRUE;

But it's not working. Does this have to do with not properly encoding my page in UTF-8? I have this in the <head> section...

Code:
<meta http-equiv="content-type" c />

and this in .htaccess

Code:
AddDefaultCharset UTF-8

because I read a couple articles saying to do that. Still no luck. How do I fix this problem?

Thanks in advance!


Form validation with special characters like accents - El Forum - 10-04-2013

[eluser]ckelly06[/eluser]
For some reason putting my <meta> tag in the forum's code brackets messes it up, but there's what it looks like:

meta http-equiv="content-type" content="text/html;charset=utf-8"