Phone Number Validation
Jeff Honken
jhonken at x12.info
Wed Feb 15 17:35:41 EST 2006
Jim,
I must be missing something. I saw that in the Docs but I couldn't
get it to work. Here's my code: Can you see why it won't validate a
000-0000 ? Jeff
--> Function
function CheckPhone pPhoneToCheck
if pPhoneToCheck is
matchText(pPhoneToCheck,"([0-9]+)-([0-9]+-[0-9]+)")
then
return pPhoneToCheck
else
return "Bad Phone"
end if
end CheckPhone
-->End of Function
--> Field Text
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
-----Original Message-----
From: use-revolution-bounces at lists.runrev.com
[mailto:use-revolution-bounces at lists.runrev.com] On Behalf Of Jim Ault
Sent: Wednesday, February 15, 2006 12:01 PM
To: How to use Revolution
Subject: Re: Phone Number Validation
On 2/15/06 9:33 AM, "Jeff Honken" <jhonken at x12.info> 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
>From the docs
matchText function
Platform support:
Introduced in version 1.0 (Changed in version 2.0)
Returns true if a regular expression is found in the specified string,
false
otherwise.
matchText(string,regularExpression[,foundTextVarsList])
matchText("Goodbye","bye") -- returns true
matchText("Goodbye","^Good") -- also returns true
matchText(phoneNumber,"([0-9]+)-([0-9]+-[0-9]+)",areaCode,phone)
HTH
Jim Ault
Las Vegas
On 2/15/06 9:33 AM, "Jeff Honken" <jhonken at x12.info> 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
>
> --> 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
>
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
subscription
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
_______________________________________________
use-revolution mailing list
use-revolution at lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your
subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
More information about the use-livecode
mailing list