phone number validation JavaScript JS

Phone number validation in JavaScript is used to make sure that all the numbers entered in the specified phone number field should be a valid phone number

Regular Expression:

/^\+(?:[0-9] ?){6,14}[0-9]$/

Example:

<!DOCTYPE html>
<html lang="en">
<head>
<script>
function phoneNumberCheck(phoneNumber)
{
var regEx = ^\+{0,2}([\-\. ])?()?([\-\. ])??([\-\. ])?\d{3}([\-\. ])?\d{4};
if(phoneNumber.value.match(regEx))
{
return true;
}
else
{
alert("Please enter a valid phone number.");
return false;
}
}
</script>
</head>
<body>
<div class="mail">
<h2>JavaScript Phone Number Validation</h2>
<form name="form1" action="#">
Phone Number: <input type='text' name='phone'/></br></br>
<input type="submit" name="submit" value="Submit"
onclick="phoneNumberCheck(document.form1.phone)"/>
</form>
</div>
</body>
</html>