Reputation: 29
if ((value.length == 12) || (value.length == 9)) {
if ((value.length == 12)) {
if (value.substring(0, 2) = "048") { //this doesn't work in the execution
return true;
} else {
return false;
}
}
if ((value.length == 9)) {
return true;
} else {
return false;
}
} else {
return false;
}
Upvotes: 1
Views: 67
Reputation: 67021
It is because you are using the JS assignment operator. Typically var a = 123;
You want to be using ===
since it doesn't do type coercion. As opposed to == which does.
if (value.substring(0,2) === "048") {
// etc
}
Upvotes: 1
Reputation: 32581
You need == like this. you cant have a single = in an if statement
if (value.substring(0,2)=="048"){
Upvotes: 1