I'm trying to create a regular expression validation form in javascript. But I'm facing a few problems while validating.
I've described the problem below with the code.
To validate the phone number, I want to have only "+" sign and numeric digits only. but as soon as I enter any alphabet then still accepts the phoneNumber
Code:
var expressionPhone =/[+]/g && /[0-9]/g && /^[a-zA-z]/g && /^[@!#$%^&*()+_-]/g;
var returnPhoneResult = cell.match(expressionPhone);
if(returnPhoneResult)
{
document.getElementById("phoneText").innerHTML = "";
}else{
document.getElementById("phoneText").innerHTML = "Incorrect Phone number entered";
}
Comments
Post a Comment