Phone Number Validation with Three Text Boxes?

  • Thread starter Thread starter Jeff Kiesel
  • Start date Start date
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) :o)
 
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
 
You could use regular expression validation on each box, should be
relatively straightforward.
 
Back
Top