您可以在 Switch 的情况下使用 IF 语句吗?
每个案例的第一个语句都可以正常工作,但 else IF 语句不能:s
任何帮助将不胜感激!
switch (units) {
case "Days" :
if (CarryQuantity > 5) {MakeFieldInvalid("CARRY_OVER", "You can only carry over a maximum of 5 days");
}
else if (CarryQuantity = 0) { MakeFieldInvalid("CARRY_OVER", "The value of holiday carry-over days must be greater than zero");
}
else {MakeFieldValid("CARRY_OVER");
}
break;
case "Hours" :
if (RGBCarryQuantity > 40) {MakeFieldInvalid("RGB_CARRY_QUANTITY_2", "You can only carry over a maximum of 40 hours.");
}
else if (RGBCarryQuantity = 0) {MakeFieldInvalid("RGB_CARRY_QUANTITY_2", "The value of holiday carry-over hours must be greater than zero");
}
else {MakeFieldValid("RGB_CARRY_QUANTITY_2");
}
break;
default :
MakeFieldValid("CARRY_OVER");
MakeFieldValid("RGB_CARRY_QUANTITY_2");
}
}