Print Page | Close Window

Problems with javascript

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Web Design Discussion
Forum Description: Discussion on web design and development subjects.
URL: https://forums.webwiz.net/forum_posts.asp?TID=9661
Printed Date: 28 March 2026 at 1:10am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Problems with javascript
Posted By: photoshop_god
Subject: Problems with javascript
Date Posted: 09 February 2004 at 12:25pm

Hi everyone,

I am having problems with some javascript.  I don't write javascript very often so this might be a really easy question to answer.

I have an asp page were people enter in information into a form.  I want to format the phone numbers and the date fields.  This is the script I have so far:

<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>

Now I have about four places to enter in phone numbers.  If I implement this as is all of the phone fields format the same.  I need each phone field to format seperatly.  Right now I'm using a javascript onblur comand on each field.  Any help would be appriciated!




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net