PDA

View Full Version : Verifying masked input for phone number


bmurtari
08-30-2006, 09:58 AM
I am trying to verify that the individual has entered ten digits in a masked DlgEditField. The mask is for a phone number and is configured as (###) ###-####. I don't care what digits they entered, just that they entered 10 of them.

- I tried testing the length of the string but it is 14 no matter what.
- I tried string trimming all the numerics, parentheses and the dash and searching for remaing spaces, that didn't work.

Any other suggestions? I really want to keep the mask to ensure standard inputs.

Any help would be greatly appreciated!

Adam
08-30-2006, 12:43 PM
Here is some code that should format the number


PhoneNum = SessionVar.Expand("%EditVar01%");
Length = String.Length(PhoneNum);

-- get rid of first bracket
PhoneNum = String.Right(PhoneNum, Length - 1);

-- get the area code
AreaCode = String.Left(PhoneNum, 3);
-- get the last 8 digits (###-####)
ActualNumber = String.Right(PhoneNum, 8);
-- get rid of the - so that the result is ########
ActualNumber = String.Left(ActualNumber, 3)..String.Right(ActualNumber, 4);
-- put the entire number in a single string
FullNumber = AreaCode..ActualNumber;