I have variable deleteboxvalue
var deleteboxvalue = "111111111111111";
if(deleteboxvalue.indexOf('0') >= 0) {
alert("You can't delete all Contact Number.");
return false;
}
else {
alert("All Zeros are not selected."); return true;
}
I want to check if 0 is not exist in this I want to return false and alert as “You can’t delete all Contact Number.” but in both cases if 0 exist in variable in that case also its returning false and giving me alert as “You can’t delete all Contact Number.”
If that’s the case then you’ve got your logic reversed. You are currently returning false if
0is in the string (i.e. it is found at an index greater than or equal to 0). If you want to return false when0is not found in the string, you can do this:However, I may have completely misunderstood what you’re trying to do…