Jump to content
Sign in to follow this  
philmck

Example of name validation could be improved

Recommended Posts

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...