I’m trying to make a textbox give a message to the user if they enter the number 1, in it for example. It should then show a pop up saying that this product is only available in multiples of 5.
Here is my code.
<script language="JavaScript">
function chk_boxquantity(inField) {
step3_submit_disable();
var fVal = inField.value;
var fBoxQuantity = 5;
if (mod(fVal, fBoxQuantity) != 5) {
alert('This product is only available in multiples of '+fBoxQuantity);
inField.value = Math.ceil(fVal/fBoxQuantity)*fBoxQuantity;
setTimeout(function() {
inField.focus();inField.select();gAutoBlur = false;
}, 10);
}
step3_submit_enable();
}
</script>
Here is the text field.
<input type="text" onkeypress="return handleEnter(this, event);"
onblur="chk_boxquantity(this);" name="qty[<?php echo $card['id']; ?>]"
size="3" />
So wherever, the user clicks, it will pop up with the message. This is not working though, any ideas why not?
Thanks,
Jonah
Change your Code From
mod()to% operatorDEMOFROM
TO
Complete Function may look like
Only required code is shown.