Ok so here's the deal... I have mostly French-speaking customers and they'll type-in their name with accents (such as é, à, è, etc.) in the following script

$string_exp = "/^[A-Za-z .'-]+$/"; 
if(!preg_match($string_exp,$prenom)) {     
$error_message .= 'Invalid name<br />';

It will say "invalid name". I know that to fix this I need to change something in the A-Za-z part of the script, but I don't know what the proper code is.

Thanks for your help, greatly appreciated!!

EDIT: I am aware that when I will receive the emails the é or à will not appear correctly and I am ok with this, but I don't want it to be a problem for the client when he sends the form.

Doesn`t anyone have an idea?

How about this.

$string_exp = "/^[A-Za-z\x80-\x95 .'-]+$/";

It doesn't work... but I just found another way to do it and it works well

$string_exp = "/^[A-Za-zé.¸UûÙùàÀèÈéÉïÏîÎôÔêÊçÇ .'-]+$/";

Thanks anyway!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.