I am looking to validate a phone number with only one character being allowed. For example, the format should be XXX-XXXXXXX where "-" is the only allowed character. Below is my validation function:
function validatePhoneNumber()
{
if(addform.staff_mobile_phone.value=="")
{
alert("Please enter the phone number");
addform.staff_mobile_phone.focus();
return false;
}
if(isNaN(addform.staff_mobile_phone.value))
{
alert("Invalid Phone Number");
addform.staff_mobile_phone.focus();
return false;
}
if((addform.staff_mobile_phone.value).length<10)
{
alert ("Phone number should be a minimum of 10 digits");
addform.staff_mobile_phone.focus();
return false;
}
return true;
}
If there are any issues with this code, please provide assistance as I really need your help.