I am trying to check some multiple conditions in JQuery but it doesn't return the desired result. whatever I input it always went to else condition.
$(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>
Aucun commentaire:
Enregistrer un commentaire