Once the page loads to the browser, ASP isn't the tool for controling the content. You need to use JavaScript.
If you want to let the user enter ANYTHING in the textbox, and then let the page go back to the server before processing (then you can use ASP). I wouldn't recommend this solution. Anytime you can move processing away from the server and onto the client is better for everyone.
The JavaScript forum will probably have a FAQ or something that can help you quickly.
Good luck. Einstein47 (Love is like PI - natural, irrational, endless, and very important.)
This is a simple page that has a form with an input box, and submit button. the form action calls the current page, formats the number (if it is a number) and displays it above the textbox if it is a 10 digit number it displays "(123)456-7890" if it is a 7 digit number it displays "123-4567"
<%
function phoneformat(phonenumber)
if isnumeric(phonenumber) then
if len(trim(phonenumber)) = 10 then phoneformat = "(" & mid(phonenumber,1,3) & "" & mid(phonenumber,4,3) & "-" & mid(phonenumber,7,4)
else
if len(trim(phonenumber)) = 7 then
phoneformat = mid(phonenumber,1,3) & "-" & mid(phonenumber,4,4)
end if
end if
end if
end function
if request.form("submit" = "submit" then
response.write(phoneformat(request.form("unformnum"))
end if
%>
<html>
<body>
<form name = "phonenumber" method = "post" action = "phone.asp">
<input type = "textbox" name = "unformnum">
<input type = "submit" name = "submit" value = "submit">
</form>
</body>
</html>
This is a simple page that has a form with an input box, and submit button. the form action calls the current page, formats the number (if it is a number) and displays it above the textbox if it is a 10 digit number it displays "(123)456-7890" if it is a 7 digit number it displays "123-4567"
<%
function phoneformat(phonenumber)
if isnumeric(phonenumber) then
if len(trim(phonenumber)) = 10 then phoneformat = "(" & mid(phonenumber,1,3) & "" & mid(phonenumber,4,3) & "-" & mid(phonenumber,7,4)
else
if len(trim(phonenumber)) = 7 then
phoneformat = mid(phonenumber,1,3) & "-" & mid(phonenumber,4,4)
end if
end if
end if
end function
if request.form("submit" = "submit" then
response.write(phoneformat(request.form("unformnum"))
end if
%>
<html>
<body>
<form name= "phonenumber" method= "post" action="phone.asp">
<input type = "textbox" name = "unformnum">
<input type = "submit" name = "submit" value = "submit">
</form>
</body>
</html>
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.