HTML, JavaScript And CSS Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingHTML, JavaScript And CSS Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old February 4th, 2004, 04:53 PM
photoshop_god photoshop_god is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 322 photoshop_god User rank is Corporal (100 - 500 Reputation Level)photoshop_god User rank is Corporal (100 - 500 Reputation Level)photoshop_god User rank is Corporal (100 - 500 Reputation Level)photoshop_god User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 1 Day 21 h 36 m 51 sec
Reputation Power: 6
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.

Reply With Quote
  #2  
Old February 4th, 2004, 05:16 PM
Memnoch's Avatar
Memnoch Memnoch is online now
Unholy Moderator
ASP Free God 14th Plane (11500 - 11999 posts)
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,770 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 7 h 3 m 32 sec
Reputation Power: 469
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.

Reply With Quote
  #3  
Old February 5th, 2004, 08:53 AM
photoshop_god photoshop_god is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 322 photoshop_god User rank is Corporal (100 - 500 Reputation Level)photoshop_god User rank is Corporal (100 - 500 Reputation Level)photoshop_god User rank is Corporal (100 - 500 Reputation Level)photoshop_god User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 1 Day 21 h 36 m 51 sec
Reputation Power: 6
Thanks Memnoch,

I'll give this a try!

Reply With Quote
  #4  
Old February 5th, 2004, 11:50 AM
photoshop_god photoshop_god is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 322 photoshop_god User rank is Corporal (100 - 500 Reputation Level)photoshop_god User rank is Corporal (100 - 500 Reputation Level)photoshop_god User rank is Corporal (100 - 500 Reputation Level)photoshop_god User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 1 Day 21 h 36 m 51 sec
Reputation Power: 6
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!

Reply With Quote
  #5  
Old February 7th, 2004, 09:33 AM
telemere telemere is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 5 telemere User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingHTML, JavaScript And CSS Help > Formatting text in an asp page


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT