|
Character validation
hello friends i want to validate only character validation for variable a & b in following code plz help.
function valid (){
a=document.form1.First.value
b=document.form1.Last.value
c=document.form1.Phone.value
d=document.form1.Suggestion.value
if(a=="")
{
alert("plz enter first name");
return false;
}
if(b=="")
{
alert("plz enter last name");
return false;
}
if(c=="")
{
alert("plz enter phone number");
return false;
}
if(isNaN(parseInt(c)))
{
alert("plz enter only number");
return false;
}
var x=document.forms["form1"]["E-mail"].value;
var atpos=x.indexOf("@");
var dotpos=x.lastIndexOf(".");
if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length)
{
alert("Not a valid e-mail address");
return false;
}
if(d=="")
{
alert("plz enter some suggestion");
return false;
}
else
{
return true;
}
}
|