NYCPHP Meetup

NYPHP.org

[nycphp-talk] Valudating common field types

Yogesh Agashe yogesh.agashe at gmail.com
Mon Oct 26 14:22:27 EDT 2009


Hello,

This is my first post to this NYPHP mailing list. So hello to everyone 
and thanks for the thorough discussions which help a beginner developer 
like me.

I have a simple question. I want to validate first and last name. I 
assume that these are probably most common fields in any type of 
registration forms on websites.

When I validate these fields, I can't use ctype_alpha since these don't 
allow ' as in O'Reilly or Last Name with white space in it. I have to 
use a regular expression here. That's fine and I use it as well. Another 
method is to find a single ' or space,  trim it and then validate 
remaining alphabet characters. RegEx is slower and even in new 
filter_input, there is no way to validate these field types.

Is there any other way to validate first and last names. It will be nice 
to have have inbuilt function for such commonly used field types. I will 
like to know how people tackle these issue.
Thanks.

Sincerely,
Yogesh







More information about the talk mailing list