Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

InputMask - Phone No (variation)

Status
Not open for further replies.

Gotheallblacks

Programmer
Oct 16, 2003
60
NZ
I am wanting to "dynamically" change the inputmask for phone numbers in a textbox as the user keys in.

eg (99)999-9999 or (999)999-9999 or (9999)999-9999 or 99-9999-9999999


I am able to determine whether .value is either a Mobile,Freephone,National or International No from the first 2-3 characters.And want the mask to change.

Does anyone have an example of how this can be done.
 

Use the interactiveChange of the textbox to evaluate each characters as they are entered.


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Mike

I had tried the following in interactiveChange:
WITH this
DO case
CASE INLIST(SUBSTR(.value,1,2),'08','05') && freephone
.inputmask='(9999)999-9999'
CASE INLIST(SUBSTR(.value,1,2),'02') && mobile phone
.inputmask='(999)999-9999'
CASE INLIST(SUBSTR(.value,1,2),'00') && INTERNATIONAL
.inputmask='99-9999999999'
OTHERWISE
.inputmask='(99)999-9999' && NATIONAL/LOCAL
ENDCASE
ENDWITH

Without much success!


 
I'd be surprised if you could pull the rug out from under Fox and change the InputMask when you're half-way through data entry.

If you use a separate textbox for the first two digits then you could change the InputMask on a second textbox to accept the rest of the number.

Geoff Franklin
 
Gotheallblacks,

I agree with Geoff. I can't see any future in changing the mask as the data is being entered.

If this was my app, I would make the users enter the formatting characters manually. Or, have 'em enter the numbers without the formatting, then, in the LostFocus, write some code that parses the number and inserts the required formatting.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
Thanks

Did the following:

in when() event of textbox

this.inputmask=''

and in both refresh() and lostfocus() methods

DODEFAULT()
WITH this
IF NOT EMPTY(.value)
DO case
CASE INLIST(SUBSTR(.value,1,2),'08','05') && freephone
.inputmask='(9999)999-9999'
CASE INLIST(SUBSTR(.value,1,2),'02') && mobile phone
.inputmask='(999)999-9999'
CASE INLIST(SUBSTR(.value,1,2),'00') && INTERNATIONAL
.inputmask='99-9999999999'
OTHERWISE
.inputmask='(99)999-9999' && NATIONAL/LOCAL
ENDCASE

ELSE
.inputmask=''
ENDIF
ENDWITH

The Idea was the user could change a National ph No to a Mobile ph etc without the restriction (visually) of the mask.

I guess closer to being user friendly reading/display but not so hot to edit.
 
Just adding: The reason for inputmask is that I didn't want format char's in the underlying data/table as it will used for dialling and faxing. and also only one class to handle phone/fax/mobile/freephone etc
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top