Ethan Rosenberg wrote:
At 07:11 AM 12/31/2010, Nathan Rixham wrote:
Ethan Rosenberg wrote:
FYI [to all the list] -- I thank all for their input. I only needed US phones, and I am forcing the user of the form to conform to xxx-xxx-xxxx as the input format.

out of interest, why are you forcing you're users to conform to that input format? you could simply strip all non-numeric chars then format how you like to save, thus giving users a looser, more friendly, experience.
Nathan -

This expression will be used to search a database which will contain patient data resulting from medical research. At the initial visit a medical record number will be assigned to the patient. Other information will be collected at that point; eg, the telephone number. At subsequent visits, the patient will be referenced by his/hers medical record number. If the patient either forgot their clinic card, or cannot remember their medical record number, a search will be performed. One of the many parameters that can be used in the search is the phone number. It is easier if all the data has a fixed format. The form for the initial visit will use a regex that will validate the phone number. As the research will be performed in the US, only US numbers have to be validated.


I think you misunderstand, I'm saying that regardless of which format you use within the system, users could enter phone numbers as "1231231234" "123 123 1234" "123-123 1234" or any variant they like, that's completely orthogonal to how you validate and save the data, in all of those cases all you need to do string non-numeric chars to validate, you may also find your indexes work that bit quicker storing numbers rather than specially (and needlessly) formatted string.

Likewise on the way back out, when presenting the numbers to users, all you need to do is string format them.


PHP General Mailing List (
To unsubscribe, visit:

Reply via email to