Here is my jsFiddle
Its on the Phone method, no the name one
Now is this line right? I only want it to be true if the first 3 letters are 087
var RightStarting3 = value.substring(0,2) == (087);
if (BlankPass || LessThan10 || RightStarting3 || GreaterThan10 || (HasSpaces > 0))
{
document.getElementById('Phone').style.background = "red";
return false;
}
else {
document.getElementById('Phone').style.background = "white";
document.getElementById("PhoneTick").style.visibility="visible";
return true;
}
087is not a string but the number which is equivalent to87. If you want a string, use a string literal like"087".=== '087', loosely comparing a string to087should generally provide the correct results. OP narrowly misses running into issues with octal numbers (077is the number63in decimal, which is misleading to beginners).