Info Path: How do I format a phone number?

P

PrettyDarnGood

I get raw numeric phone numbers from the SQL database and I want those
numbers to have a Mask in the input screen. The user enters just numbers, but
the appearance is (999) 999-9999. I don't want the formatting symbols
submitted to the database. It seems that there would be an XSLT
representation of the phone number, but I don't know how to implement it.

Sincerely.
Steve Simon
 
M

Michelle

There is no input mask capability in InfoPath. However you can do a
combination of the following:
(1) Use validation on the control to make sure the users enter phone
numbers using (123) 456-7890 format
(2) Write custom code on the save event (or submit - whatever you are
doing) that updates the phone number node value to replace '(', ')', '
' and '-' with '' so you end up with only the digits to be stored in
the DB.

When retrieving data write custom code to readd the '(', ')', ' ' and
'-' to the phone number in the xml datasource so it is displayed
correctly in the form.

Michelle
 
P

Patrick Halstead

The regular expression support that Michelle mentions in #1 is pretty cool.
 
S

Steve Simon

Thank you, Michelle.

Sincerely,
Steve Simon

Michelle said:
There is no input mask capability in InfoPath. However you can do a
combination of the following:
(1) Use validation on the control to make sure the users enter phone
numbers using (123) 456-7890 format
(2) Write custom code on the save event (or submit - whatever you are
doing) that updates the phone number node value to replace '(', ')', '
' and '-' with '' so you end up with only the digits to be stored in
the DB.

When retrieving data write custom code to readd the '(', ')', ' ' and
'-' to the phone number in the xml datasource so it is displayed
correctly in the form.

Michelle
 
R

rharmer

Any chance you can provide the custom code?

Michelle said:
There is no input mask capability in InfoPath. However you can do a
combination of the following:
(1) Use validation on the control to make sure the users enter phone
numbers using (123) 456-7890 format
(2) Write custom code on the save event (or submit - whatever you are
doing) that updates the phone number node value to replace '(', ')', '
' and '-' with '' so you end up with only the digits to be stored in
the DB.

When retrieving data write custom code to readd the '(', ')', ' ' and
'-' to the phone number in the xml datasource so it is displayed
correctly in the form.

Michelle
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top