Formatting social security number

B

Bob B

How can I have the dashes automatically placed when I enter the digits of a
social secutity number xxx-xx-xx. It is a text field.
 
B

Bob B

I tried that. There is no formating options available for text string, unless
is under the placeholder option. I have infopathe 2003. I know you can
formant SSN in ACCESS
 
C

Clay Fox

Sorry Bob,

My Bad.

You have to go to Properties, Display tab, and then Conditional Formatting

Add a new one and then on the drop down for equals switch it to matches
pattern. Then you can select a pattern and SSN is the second on the list.

Have fun.

--
Thanks

Clay Fox

Qdabra Software
http://www.qdabra.com

InfoPathDev.Com
The Largest InfoPath Forum in the World
http://www.infopathdev.com
 
B

Bob B

I know this is a little delayed. I tried your suggestion and was able to
follow it exactyly but when I tried typing in the soc sec no. it didn't take
I expected to type xxx and the - would appear and then xx and annother dash.
Sorry to be so late to respond but this project has a low priority.
 
G

Greg Collins

You can use this as a default value formula, although it has the side effect
of placing "--" in the field if it is blank:

concat(substring(translate(., "-", ""), 1, 3), "-", substring(translate(.,
"-", ""), 4, 2), "-", substring(translate(., "-", ""), 6, 4))
 
B

Bob B

This works but you also must change alignment to justif under display tab.
If there is a drop down list box, date,etc preceding the field you want to
edit with dashes the cursor goes solid on the dashes and when you type the
dashes are removed. Any thoughts on this?
 
D

Dirty Russian

Thanks Greg,
This works great for me Thank you,

concat(substring(translate(., "-", ""), 1, 3), "-",
substring(translate(.,
"-", ""), 4, 2), "-", substring(translate(., "-", ""), 6, 4))


One thing I must say though, set the field as string (to accommodate
dashes). Then add that formula as a rule that runs when data changes
(set . value). Also change the last "4" to a "9" to accommodate longer
strings without truncating. Then set the data validation for that
field to SSN.

Result:
When you enter a number it auto formats. If you fat finger and have a
extra digit it shows up as xxx-xx-xxxxx.... at which point data
validation highlights it in red.

This of course is still a little rough because you are not saving 9
integers which may cause trouble for future programming but it makes a
nice looking form fairly easily.
 

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