Mobile validation in Java scripts
----------------------Java Script for Contacts & mobile------------------------
<script language="javascript">
function Validate()
{
var x = document.form1.txtPhone.value;
if(isNaN(x)||x.indexOf(" ")!=-1)
{
alert("Enter numeric value")
return false;
}
if (x.length>8)
{
alert("enter 8 characters");
return false;
}
if (x.charAt(0)!="2")
{
alert("it should start with 2 ");
return false
}
var y = document.form1.txtMobile.value;
if(isNaN(y)||y.indexOf(" ")!=-1)
{
alert("Enter numeric value")
return false;
}
if (y.length>10)
{
alert("enter 10 characters");
return false;
}
if (y.charAt(0)!="9")
{
alert("it should start with 9 ");
return false
}
}
-----------------------------------------------------------------
Comments
Post a Comment