当我使用此:
case "vic":
if ((bPostcodeSubstring == 3) || (bPostcodeSubstring == 8)){
return true;
}
else{
errMsg += "Enter A Valid Postcode.";
result = false;
}
break;
一切正常。但是当我使用这个:
case "vic":
if ((bPostcodeSubstring != 3) || (bPostcodeSubstring != 8)){
errMsg += "Enter A Valid Postcode.";
result = false;
}
break;
它根本不起作用。有什么问题?
最佳答案
!((bPostcodeSubstring == 3) || (bPostcodeSubstring == 8))
与...不同
(bPostcodeSubstring != 3) || (bPostcodeSubstring != 8)
它应该是
(bPostcodeSubstring != 3) && (bPostcodeSubstring != 8)
迪摩根定律
关于javascript - 不等于不能在javascript中工作,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/23194623/