Hello
I have been trying to make a php code for telephone form field validation for international numbers. When a user lets the field empty it shows a popup display. If the user fills in the field then it has to be filled in rightly. It has errors I am not able to work it. Can someone help ?
Thanks for a possible help.
Ron
I have been trying to make a php code for telephone form field validation for international numbers. When a user lets the field empty it shows a popup display. If the user fills in the field then it has to be filled in rightly. It has errors I am not able to work it. Can someone help ?
$answer = true;
$submit = addEvent('click', function(event) {
//Read the value from the form input
var phoneNumber = $('phonebox').value;
//IF the length of the phonenumber is 0, then we ask the user about it...
if (phoneNumber.length == 0)
{
//IF the user also presses Cancel, we will approve the form submission!
if (!confirm("A \"Customer Resource\" executive can provide you Better Support through telephone.\n \n We are a responsible company and provides service to its worldwide customers effectively. \n \n To provide us your telephone number just press\"Ok\" or else press \"Cancel\". "))
{
return true;
} else
{
return false;
}
} else if (phoneNumber.length != 13)
{
alert("Invalid phone number length! Please try again.");
return false;
//Use a regular expression to see whether the phone number only contains digits...
} else if (!phoneNumber.match(/^((\+)?[1-9]{1,2})?([\-\s\.])?((\(\d{1,4}\))|\d{1,4})(([\-\s\.])?[0-9]{1,12}){1,2}(\s*(ext|x)\s*\.?:?\s*([0-9]+))?$/ –))
{
alert("Invalid characters in your phone number. Please try again.");
return false;
}
return true;
}
Thanks for a possible help.
Ron