Sign in to follow this  
Followers 0
philmck

Example of name validation could be improved

1 post in this topic

Hi, I love all the tutorials on this site, generally very clear and uncluttered. Thank you for making them available, they must have taken a lot of work.

 

The PHP Form Validation page at http://www.w3schools.com/php/php_form_url_email.asp however has a bad example of name validation that would cause problems for a lot of people because it's too restrictive. Many names contain apostrophes, hyphens, initials, abbreviations, accents and so on. It's a common error and it's a shame to see it encouraged here.

 

I realise you're using it as an example of a preg_match but this is not a good place to do it.

 

I suggest changing the example test to allow only printable characters, e.g. using ctype_print().

 

It's good that you don't expect everyone to have a firstname and lastname, though.

Edited by philmck

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0