Phone Fromat (999) 999-9999

YoG

New Member
Hello everyone,

I know this should be easy to do, but I have no imagination this morning.

I have a character field with the format (999) 999-9999 . I want to be able to have it blank. But the format with 9 needs to be a number and cannot be blank, therefore I have a Progress message indicating that a numeric must be in the second position. I know this has been done before, and I never had to program it.

Any idea?

Thanks.
 
Phone Format (999) 999-9999

I tried something and it worked. If you have any other idea, please post.

Here is how I did it.

On the entry I'm changing the format of the field to "(999) 999-9999". On the leave I change it to "(XXX) XXX-XXXX". That way it won't take the character when they are trying to type the phone number, but it will no longer give the error if the field is blank. I know the ? is possible, but I don't want it on the database.

If you have any other way, please post it, it can help.

Thanks for reading.
 
Sorry, it's late - hit the wrong button - doh.

Starting again...

Set the field:FORMAT = '(XXX) XXXX-XXXX'.

Then ON LEAVE OF field:

DO cntr = 1 TO LENGTH(field):

IF SUBSTRING(field,cntr,1) <> 'X' OR
(ASC(SUBSTRING(field,cntr,1)) > 47 AND
ASC(SUBSTRING(field,cntr,1)) < 58) THEN.
ELSE
DO:
MESSAGE 'Character' TRIM(STRING(cntr)) 'is invalid'.

APPLY 'ENTRY' TO SELF.

RETURN NO-APPLY.
END.
END.

Quick and dirty but it works.
 
Back
Top