PDA

View Full Version : Why Does This Script Alert Twice?


ladybugz46
11-07-2002, 05:50 PM
Can anyone help....this is a phone number validation script that I have modified...it alerts twice with any error and I don't understand why.

How could I re write this so it alerts just once.....Thanks in advance...suez

<head>
<script language="javascript">
function checkPhone() {
var stripped = document.ordr.P2.value;
var stripped = stripped.replace(/[\(\)\.\-\ ]/g, '');
if ((isNaN(parseInt(stripped)) || (!(stripped.length == 10))))
alert ("You have entered:" + "\n\n" + stripped + "\n\n" + "Please check your phone number and re-enter. ");
}
</script>
</head>
<body>
<body>
<form name="ordr"><td valign="top">&nbsp;<font face="Arial, Helvetica,sans-serif" size=1><b>Phone Number</b><font face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular" color="#ff0000" size="1">&nbsp;*</font><br>&nbsp;
<input type="text" size=12 name="P2" maxlength=12 tabindex=12 onblur="checkPhone()"></td></form>
</body>

Simrey
11-07-2002, 06:24 PM
Computers, eh! Who needs 'em? I just tested your code on my machine (running IE4) and damned if I could get it to do more than one alert... tabbing out, clicking out .. nothing doing!

Maybe it's different with the rest of the form present?

Borgtex
11-07-2002, 06:31 PM
The same for me with IE 5.5: Only 1 alert when you go out of the input box

ladybugz46
11-07-2002, 07:29 PM
Thanks everyone....I feel silly....but I fully installed the script on our site and it is working correctly.

I had been testing from Homesite 4.5....and from there I was indeed getting double alerts.

You are all very gracious with your help! Thank you! suez