Phone Number Validation

Alex Tweedly alex at
Wed Feb 15 13:13:59 CST 2006

Jeff Honken wrote:

>I'm trying to validate a date.  I've been playing with the below code
>but I can't get it to verify a correct phone number.  Can anyone steer
>me in the correct direction on how to verify a phone number in a field
>for the correct format?  Jeff
Jeff, you need something more like

> function CheckPhone pPhoneToCheck
>   put "([0-9][0-9][0-9])-([0-9][0-9][0-9])-([0-9][0-9][0-9][0-9])" 
> into reg
>   return matchText(pPhoneToCheck, reg)
> end CheckPhone

>--> Code in Filed
>on closeField
>put CheckPhone(me) into Ewr
>  if Ewr is "Bad Phone" then
>    answer "The Telephone Number you entered must be in the format of
>    put "" into me
>    focus on me
>    break
Oooooh - one little mistype and you take away all my typing and I need 
to re-do it !
The way I type, I'd probably never succeed in completing  that field ....

btw - there are all kind of other phone formats you may want to allow 
(even within the) US.
A quick Google of "regular expression phone number" will give you more 
ideas than you want ....

Alex Tweedly

No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.375 / Virus Database: 267.15.8/260 - Release Date: 14/02/2006

More information about the use-livecode mailing list