|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Formatting text in an asp page
Hi,
I have a several asp pages that will have multiple people entering in information. I would like to have them just type in the numbers and have script format the field as it goes. I have seen this done on sites like turbo tax. Here is an example of what I'm looking for: I'm using asp and an access database on this site. I have a text box that holds the clients phone number. I would like to have all the phone numbers formated like this (123)456-7890. I would like the brackets and the dashes added as the person is entering in the number. So all they would have to do is type 1234567890. I really want to keep all the dates and phone numbers formated the same! I'm assuming that I will have to use javascript, but I have not found any good resources or sample scripts. Any help would be appreciated. |
|
#2
|
||||
|
||||
|
you can try this
Code:
<script language="JavaScript">
function formatPhone(phoneValue)
{
var areaCode, three, four
var areaCode = phoneValue.substring(0, 3);
var three = phoneValue.substring(3, 6);
var four = phoneValue.substring(6, 10);
document.form1.phone.value = "(" + areaCode + ")" + " " + three + "-" + four
}
function formatDate(dateValue)
{
var m, d, y
var m = dateValue.substring(0, 2);
var d = dateValue.substring(2, 4);
var y = dateValue.substring(4, 8);
document.form1.startDate.value = m + "/" + d + "/" + y
}
</script>
<form name="form1">
<input name="phone" type="text" size="25" onBlur="javascript:formatPhone(this.value)"><br>
<input name="startDate" type="text" size="25" onBlur="javascript:formatDate(this.value)">
</form>
The formatDate function assumes the user enters the date in the (mmddyyyy) format, like this 02042004. Which would display it like 02/04/2004 in the box. |
|
#3
|
|||
|
|||
|
Thanks Memnoch,
I'll give this a try! |
|
#4
|
|||
|
|||
|
Hey that worked great. I only have one question. I have about 4 phone numbers that have to be entered into this form.
<input name="x_HOMEPHONE" type="text" size="25"> <input name="x_WORKPHONE" type="text" size="25"> and so on. I'm relativey new to javascipt, but the things I have tried only copy the information and format onto the rest of the phone number fields. I need to enter in four or five different numbers all with the same format. Thanks in advance for any help! |
|
#5
|
|||
|
|||
|
How do I post a new topic or issue in this thing
I'm new to this forum and would like to ask a question.
Well my question is I have a query that generates a list and that list to long so I'm getting an access database limit exceeded error. What I want to do is break the list down to be divided alphabetical. so you click on a or b etc and it gives only the results that begin with those letters. Thanks |
![]() |
| Viewing: ASP Free Forums > Programming > HTML, JavaScript And CSS Help > Formatting text in an asp page |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|