Revision: 32736
Updated Code
at October 2, 2010 01:32 by jprochazka
Updated Code
<head>
...
<script language="JavaScript" type="text/javascript">
function nameCheck() {
}
function teleCheck(teleStr) {
alert(teleStr);
var stripped = teleStr.replace(/[\(\)\.\-\ ]/g, '');
if (teleStr == "") {
alert("You must supply a phone number.");
return false;
} else if (isNaN(parseInt(stripped))) {
alert("The supplied phone number contains illegal characters.");
return false;
} else if (!(stripped.length == 10)) {
alert("Supplied phone number is the wrong length.\nBe sure to included an area code.");
return false;
}
return true;
}
</script>
...
</head>
...
<body>
...
<form id="form1" name="form1" method="post" onSubmit="return teleCheck(this.telephone.value)" action="">
...
Revision: 32735
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at October 2, 2010 01:32 by jprochazka
Initial Code
<head>
...
<script language="JavaScript" type="text/javascript">
function nameCheck() {
}
function teleCheck(teleStr) {
alert(teleStr);
var stripped = teleStr.replace(/[\(\)\.\-\ ]/g, '');
if (teleStr == "") {
alert("You must supply a phone number.");
return false;
} else if (isNaN(parseInt(stripped))) {
alert("The supplied phone number contains illegal characters.");
return false;
} else if (!(stripped.length == 10)) {
alert("Supplied phone number is the wrong length.\nBe sure to included an area code.");
return false;
}
return true;
}
</script>
...
</head>
...
<body>
...
<form id="form1" name="form1" method="post" onSubmit="return teleCheck(this.telephone.value)" action="">
...
Initial URL
Initial Description
The following JavaScript will validate if a 10 digit phone number was supplied once the form is submitted.
Initial Title
Validte a telephone number.
Initial Tags
validation
Initial Language
JavaScript