Phone Number Validation with Three Text Boxes?

J

Jeff Kiesel

Has anyone used three textboxes for phone number input and successfully
validated it?

One textbox for area code, one for exchange, one for number. (yes, we're
only doing US numbers) :eek:)
 
K

Kevin Parkinson

Jeff:
Have you tried it yet? It doesn't seem like it would be hard to do.
Do you mean validating whether it is a real phone number, or just validating
the characters? I would use web controls for this, you know the
<asp:textbox... things, and set the max length accordingly, then write some
little functions such as ( I am into C# these days ):

public bool hasIllegalCharacters( String s )
{
if ( s has things like %, !, /, <SCRIPT> or INSERT in it )
{
return false;
}
return true;
}

then from lets say, a forms submit button click event:

String pnumber;
pnumber = ac.Text + ex.Text + number.Text;
if ( this.hasIllegalCharacters( pnumber) )
{
Response.Redirect("error.aspx");
}
else
{
Response.Redirect("Validated.aspx")
}

Is that what you were wondering?

Kevin Parkinson
 
R

Rick Spiewak

You could use regular expression validation on each box, should be
relatively straightforward.
 

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

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top