Hey,
I have this code that works fine in IE, but it totally chokes in Firefox.
Type in an invalid phone number in the phone number field, then tab to the next field, and you'll see the alert popup, but the field doesn't focus again requiring them to leave it empty or valid, like it should. Here's the code. Any ideas?
Thanks,
Rick
RISTMO Designs: Rockwall Web Design
Arab Church: Arabic Christian Resources
Genuine Autos: Kaufman Chevrolet & Pontiac Dealer
Rick Morgan's Official Website
I have this code that works fine in IE, but it totally chokes in Firefox.
Type in an invalid phone number in the phone number field, then tab to the next field, and you'll see the alert popup, but the field doesn't focus again requiring them to leave it empty or valid, like it should. Here's the code. Any ideas?
Code:
function ValidateUSPhone (theField)
{
var msg = "";
var theString = "";
var msgInvalid = "Please enter a valid U.S. phone number.\nSuch as (760) 555-1212"
theString = theField.value;
if (theString != "")
{
theString = StripChars(theString)
if (!AllInRange("0","9",theString))
{
msg = msgInvalid;
}
else if (theString.length == 11)
{
if (theString.charAt(0) != "1")
msg = msgInvalid
}
else if (theString.length != 10 && theString.length != 7)
{
msg = msgInvalid
}
if (msg == "")
{
if (theString.length == 10)
theString = reformat(theString,"(",3,") ",3,"-",4);
else if (theString.length == 7)
theString = reformat(theString,"",3,"-",4);
else //len == 11
theString = reformat(theString,"",1,"(",3,") ",3,"-",4);
theField.value = theString;
}
else
{
alert(msg);
theField.focus();
}
}
}
Thanks,
Rick
RISTMO Designs: Rockwall Web Design
Arab Church: Arabic Christian Resources
Genuine Autos: Kaufman Chevrolet & Pontiac Dealer
Rick Morgan's Official Website