0

In my form, i do some verifications before registering in database

    if( isset($form['lastname']) && !empty($form['lastname']) && !preg_match ('/[^a-z]/i', $form['lastname']))

{

}

this does not accept accents like "benoît" or "hélène"

Does anyone know to make them allowed ? thanks in advance

  • Omit the `prey_match` check? What is it for? What do you want to allow and what do you want to disallow? – deceze Jan 03 '13 at 13:50
  • Greetings i want to disallow numbers –  Jan 03 '13 at 13:50
  • Only numbers? What about "!"? Or "$"? Or "風"? – deceze Jan 03 '13 at 13:52
  • It also doesn't accept `O'Brien` or `Reece-Jones`, or any number of other valid names. And that's just common English names. Bottom line: Don't even attempt to validate people's names. Reference: http://stackoverflow.com/questions/3853346/how-to-validate-human-names-in-cakephp/3853820#3853820 – SDC Jan 03 '13 at 14:14

1 Answers1

1

French accents, as same as German Umlauts etc. are words beyond A-Z.

If you need to filter numbers (0-9), you can use smth. like this (not recomended).

if( isset($form['lastname']) && !empty($form['lastname']) && !preg_match ('/[^0-9]/i', $form['lastname'])) {

}
mate64
  • 9,876
  • 17
  • 64
  • 96
  • The question is: can you be certain that no-one has a name that contains a digit? *Absolutely* certain?? Sure, John Smith III may use roman numerals for his name, but that's just convention; what's to stop someone else deciding to use "The 3rd" instead? – SDC Jan 03 '13 at 14:19