Phone Number Validation : Validation : Form Control JAVASCRIPT DHTML TUTORIALS


JAVASCRIPT DHTML TUTORIALS » Form Control » Validation »

 

Phone Number Validation




<html>
<head>
<title>Phone Number Validation</title>
<script language="JavaScript">
<!-- 
function validatePhone(areaCode,prefix,extension)
{
  var phoneNum = new String(areaCode + "-" + prefix + "-" + extension);
   
  var regExpObj = /(ddd)-ddd-dddd/;
   
  if(regExpObj.exec(phoneNum== null)
  {
    alert(phoneNum + " does not contain a valid code!");
  }
  else
  {
    alert("Thank you for your order!");
  }
}
// end script-->
</script>
</head>
   
<body>
<center>
<h1>Phone Number Validation</h1>
<form name="form1">
Phone Number: 
<input type="text" size=maxlength=name="area">-
<input type="text" size=maxlength=name="prefix">-
<input type="text" size=maxlength=name="extension">
<br><br>
<input type="button" value="Submit" onClick="validatePhone(area.value, prefix.value, extension.value)">
</form>
</center>
</body>
</html>

           
       



-

Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .

Follow Navioo On Twitter

JAVASCRIPT DHTML TUTORIALS

 Navioo Form Control
» Validation