Hello all,
I have written this javascript below. What the script does is checks the quantity entered by the user (on the fly) and compares the input to the increments required.
1 thru 47 *must order increments of 2
48 - 96 *must order increments of 48
96++ *must order in increments of 96
Everything works fine with exception to numbers 1 - 9.
The problem is that when entering, let's say 33, the first digit gets read and prompts 'increments of 2' instead of allowing the full number to be processed.
Any ideas? Thanks in advance..
I have written this javascript below. What the script does is checks the quantity entered by the user (on the fly) and compares the input to the increments required.
1 thru 47 *must order increments of 2
48 - 96 *must order increments of 48
96++ *must order in increments of 96
Everything works fine with exception to numbers 1 - 9.
The problem is that when entering, let's say 33, the first digit gets read and prompts 'increments of 2' instead of allowing the full number to be processed.
Any ideas? Thanks in advance..
Code:
<html>
<head>
<script language="javascript">
<!--//
var input;
var qty;
function getQuantity(number) {
input = number;
checkQuantity();
}
function checkQuantity() {
qty = input.value;
if (qty < 48) {
if (qty%2 != 0 && qty.length >= 2) {
alert('Select quantity in increments of 2');
document.this_form.quantity.value = "";
}
}
else
if (qty >= 48 && qty < 96) {
if (qty%48 != 0) {
alert('Select quantity in increments of 48');
document.this_form.quantity.value = "";
}
}
else
if (qty >= 96) {
if (qty%96 != 0) {
alert('Select quantity in increments of 96');
document.this_form.quantity.value = "";
}
}
setTimeout(checkQuantity, 100);
}
//-->
</script>
<title>My Script</title>
</head>
<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" rightmargin="0" bottommargin="0" marginwidth="5" marginheight="0">
<br>
<form method="POST" name="this_form">
INPUT: <input type="text" name="quantity" size="40" onClick="getQuantity(this)">
<input type="submit" value="Select">
</form>
<br>
</body>
</html>