I am a beginner in javascript and am not sure what is going wrong in the code below. It doesn't show any alert when a wrong number is entered. Thanks for the help.The html code for the the attribute is
<li><label for="phonenumber">Phone:</label></li>
<li><input type="tel" name="phonenumber" /></li>
Validation code:
function formValidation()
{
var uphone = document.registration.phonenumber;
{
if(ValidatePhone(uphone))
}
return false;
}
function ValidatePhone(uphone)
{
var phoneformat = /(^\d{3}-\d{3}-\d{4})$/;
if(uphone.value.match(phoneformat))
{
return true;
}
else
{
alert('You have entered an invalid phone number!');
uphone.focus();
return false;
}
}