Phone Number Validation
Jim Ault
JimAultWins at yahoo.com
Wed Feb 15 18:19:21 EST 2006
On 2/15/06 2:35 PM, "Jeff Honken" <jhonken at x12.info> wrote:
> 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
First, realize that matchText is a FUNCTION.
--as are matchChunk & replaceText
--'replace' is a command, as are 'put, get, delete'
Second, decide what variables you want to end up with and use parens in
accordance. In the docs it shows 'areacode' & 'phone'
As result, try using either the first technique or the second one
------------ first -------------
get matchText( pPhoneToCheck, "(regExpr)-( regExpr)", areacode, phone)
answer it -- should be 'true'
--thus the matchText FUNCTION does two things
-- 1 returns a true/false so you can test success
-- 2 puts the value in parenthesis into each variable name supplied
answer areaCode & cr & phone & cr "do what you want with these"
------------ second -------------
This would be the syntax I would use to make things a bit easier:
put "([0-9]+)-([0-9]+-[0-9]+)" into regEx
get matchText( pPhoneToCheck, regEx, areacode, phone)
answer it
answer areaCode & cr & phone & cr "do what you want with these"
HTH
Jim Ault
Las Vegas
On 2/15/06 2:35 PM, "Jeff Honken" <jhonken at x12.info> wrote:
> 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
>
>
>
> _______________________________________________
> 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