我正在尝试在JQuery中检查某些多个条件,但未返回所需的结果。无论我输入什么,它总是进入其他条件。
$(function() {
$('#installment').on("keydown keyup", check);
function check() {
var inst = Number($("#installment").val());
if (inst === 2 || inst === 4 || inst === 6 || inst === 12) {
return true;
} else {
$("#installment").val('');
alert("you can not set wrong value");
return false;
}
}
});
<script src="https://code.jquery.com/jquery-3.3.1.js"></script>
<tr>
<td>Number of Installment</td>
<td><input type="text" name="installment" id="installment"></td>
</tr>
慕标琳琳
相关分类