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"> <font face="Arial, Helvetica,sans-serif" size=1><b>Phone Number</b><font face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular" color="#ff0000" size="1"> *</font><br>
<input type="text" size=12 name="P2" maxlength=12 tabindex=12 onblur="checkPhone()"></td></form>
</body>
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"> <font face="Arial, Helvetica,sans-serif" size=1><b>Phone Number</b><font face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular" color="#ff0000" size="1"> *</font><br>
<input type="text" size=12 name="P2" maxlength=12 tabindex=12 onblur="checkPhone()"></td></form>
</body>