Phone Number Validation

Eric Chatonet eric.chatonet at sosmartsoftware.com
Wed Feb 15 15:25:03 EST 2006


Hi Jeff,

I have read the clever answers made to your request.
Just a thought :-)
If your phone numbers are entered by the user in your software, you  
might just allow to enter a right phone number in the entry box.
Something like (in the script of your entry box):

on keyDown pKey
   if pKey is an integer and the number of chars of me < 8 then then  
pass keyDown
end keyDown
----------------------------
on closeField -- auto formatting
   put char 1 to 3 of target & "-" & char 4 to 6 of target & "-" &  
char 7 to 8 of target into target
end closeField

Sorry if it does not apply ;-)

Best Regards from Paris,
Eric Chatonet

Le 15 févr. 06 à 18:33, Jeff Honken a écrit :

> 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
>
> --> Function
> function CheckPhone pPhoneToCheck
>   if pPhoneToCheck is
> matchText(pPhoneToCheck,"([0-9][0-9][0-9])-([0-9][0-9][0-9])-([0-9] 
> [0-9]
> [0-9][0-9])")
>     then
>     return pPhoneToCheck
>   else
>     return "Bad Phone"
>   end if
> end CheckPhone
> -->End of Function
>
>
> --> 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
> 000-000-0000"
>     put "" into me
>     focus on me
>     break
>
>   ELSE
>
>     Answer "OK Good Number"
>
>   END IF
> end closeField

------------------------------------------------------------------------ 
----------------------
http://www.sosmartsoftware.com/    eric.chatonet at sosmartsoftware.com/





More information about the use-livecode mailing list