var g = document.frm;
if(trim(g.phone.value)=="")
{
alert("Please enter phone no.");
g.phone.value = trim(g.phone.value);
g.phone.focus();
return false;
}
if(!validatePhone(g.phone.value))
{
alert("Please enter valid phone no. like 222-222-2222.");
g.phone.value = trim(g.phone.value);
g.phone.focus();
return false;
}
function validatePhone(number)
{
var textV = number;
var reg = new RegExp("^[0-9]{3}-[0-9]{3}-[0-9]{4}$", "i")
if(textV.match(reg)) {
return true;
} else {
return false;
}
}
No comments:
Post a Comment