Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Phone Number Format Issue 1

Status
Not open for further replies.

Figzus

Programmer
Mar 21, 2005
36
0
0
US
Okay this probably seems like a really dumb question but I have no idea how to do it. How do you take a phone number like this 0123456789 and break it down into 3 differnt text boxes? I have a huge text box that it populates when the page loads Im just wandering how do I break it down into 3 different text boxes instead of using one giant one. Thanks
 
<%
Dim myPhoneNum
myPhoneNum = "0123456789"
%>
<input type='text' name='boxen1' value='<%= Left(myPhoneNum, 3)%>'>
<input type='text' name='boxen2' value='<%= Mid(myPhoneNum, 4,3)%>'>
<input type='text' name='boxen3' value='<%= Mid(myPhoneNum, 7)%>'>
 
Something like this you mean?
Code:
<%
Dim strNumber, strLeft, strMiddle, strRight

strNumber = "0123456789"

strLeft = Left(strNumber, 3)
strMiddle = Mid(strNumber, 4, 3)
strRight = Right(strNumber, 4)
%>

<input type="text" name="left" value="<%=strLeft%>" />
<input type="text" name="middle" value="<%=strMiddle%>" />
<input type="text" name="right" value="<%=strRight%>" />

Tony
[red]_________________________________________________________________[/red]
Webmaster -
 
You might want to add some extra error checking. For example checking for an empty phone number or one with only 7 digits or one where someone added the "1" in front for long distance... or rejecting numbers that are not the correct length or whatever.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top