Solved

Masking the phone and social security number entries with dashes

Posted on 2004-08-05
7
1,321 Views
Last Modified: 2008-02-01
Right now the text box controls on my program will only restrict the users to 12 characters for the telephone field and 11 characters for the social security number.  However some of my users are not using dashes to separate the numbers properly and this is causing problems in reports since they are harder to read. How can I let my users enter just the numbers and do the masking programmatically behind the scenes and then display their output in the textbox with the dashes in the proper positions?

My second question is related to the first one:  Some users have in the past used dots (.) to separate and mask these numbers - how can I parse through these numbers as they are retrieved and replace the dots with the proper dashes?

Thank you.

0
Comment
Question by:amutlu67
  • 4
  • 2
7 Comments
 
LVL 7

Expert Comment

by:mdamico
ID: 11732521
Seperate the SSN and Telephone number fields to 3 textboxes each

For SSN it would look like
<Textbox maxlength=3> - <Textbox maxlength=2> - <Textbox maxlength=4>

Set up an autotab function(press 3rd character in first box, autotab to second box....)
Validate that only numbers were added into each box and the correct amount of characters in each box.

This takes care of all seperators a user may enter.

Wasn't sure if this was ASP.Net of WindowsForms.Net or I would be more specific.
0
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 11732964
use regexps ...

SSN
"^\d{3}-\d{2}-\d{4}$"

Phone Number
"^[2-9]\d{2}-\d{3}-\d{4}$"

both enforce - in correct locations


as for how to replace the previous ones with .

string foo = YourNumber;
foo.Replace(".","-");

you can also do this string operation in SQL if need be but the syntax is a bit different.
0
 

Author Comment

by:amutlu67
ID: 11743968
Sorry - I guess I needed to be more specific mdamico;
I am using windows forms on the front end...and if at all possible, I would like to keep the same number of text boxes rather than splitting the fields with text boxes - otherwise I will need to readjust my tab indexes and I have over 100 fields on the form!

gregoryyoung:
I keep seeing mention of regular expressions: what are these? - I think this is the way to go but the syntax is not familiar to me.  Is it a part of vb.net syntax? can you post an example or a link to an example so I can figure out how these work?  If it's easier for you, you can also give me the example in SQL.

Thank you both,

am
0
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 37

Expert Comment

by:gregoryyoung
ID: 11744084
http://aspzone.com/articles/173.aspx even includes a function to validate SSN ... modifying it for your phone numbers is just changing the regexp :)
0
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 11744104
oops thats classic asp ...

http://www.dotnetspider.com/Technology/KB/ShowSample.aspx?SampleId=80 works a bit better ...

Function IsValidEmail(strIn As String) As Boolean
    ' Return true if strIn is in valid e-mail format.
    Return Regex.IsMatch(strIn, ("^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$")
End Function
0
 
LVL 37

Accepted Solution

by:
gregoryyoung earned 500 total points
ID: 11744109
so ....

Function IsValidSSN(strIn As String) As Boolean
    ' Return true if strIn is in valid e-mail format.
    Return Regex.IsMatch(strIn, "^\d{3}-\d{2}-\d{4}$")
End Function

Function IsValidPhone(strIn As String) As Boolean
    ' Return true if strIn is in valid e-mail format.
    Return Regex.IsMatch(strIn,"^[2-9]\d{2}-\d{3}-\d{4}$")
End Function

0
 

Author Comment

by:amutlu67
ID: 11772807
gregoryyoung,

Thank you so much for your help - I greatly appreciate it.

AM
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question