| Phone Number Validation Using javaScript
|
|
Phone validation:
Example
<html>
<head>
<script type="text/javascript">
function validation()
{
var a = document.form.phone.value;
if(a=="")
{
alert("Please Enter Your Phone Number");
document.form.phone.focus();
return false;
}
}
</script>
</head>
<body>
<form name="form" method="post" onsubmit="return validation()">
<tr>
<td> Phone:</td>
<td><input type="text" name="phone""></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="sub" value="Submit"></td>
</tr>
</form>
</body>
</html>
|
|
|
The Output is Shown Here:
|
Phoneno Validation
Example
<html>
<head>
<script type="text/javascript">
function Validation()
{
var a = document.form.phone.value;
if(a=="")
{
alert("please Enter the Contact Number");
document.form.phone.focus();
return false;
}
if(isNaN(a))
{
alert("Enter the valid Phone Number(Like : 044-42046569)");
document.form.phone.focus();
return false;
}
}
</script>
</head>
<body>
<form name="form" method="post" onsubmit="return Validation()">
<tr>
<td> Phone No:</td>
<td><input type="text" name="phone""></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="sub" value="Submit"></td>
</tr>
</form>
</body>
</html>
|
|
|
The Output is Shown Here:
|