Solved

Masking the phone and social security number entries with dashes

Posted on 2004-08-05
7
1,316 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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

759 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now