I have been trying to get this to work for the last few hours with no luck. I'm convinced there's something obvious that I am missing but I just cannot see it!
For info, the "minimumQuantity" is a <span id> generated by my client's site's eCommerce software, for example:
I've checked that this is the only span with this ID on the product detail page. If there is no minimum quantity, "Not applicable" is generated instead of a number.
Under the example of a minimum quantity of 8:
Code:
For info, the "minimumQuantity" is a <span id> generated by my client's site's eCommerce software, for example:
Code:
<span id="minimumQuantity">8</span>
Under the example of a minimum quantity of 8:
- The error is displayed if you enter 7 or less (including minus numbers) into the quantity field. This is correct.
- The error is NOT displayed if you enter 8 or 9 into the quantity field. This is correct.
- The error IS displayed if you enter between 10-79 in the quantity field. This is NOT correct.
- The error is NOT displayed if you enter between 80-99 in the quantity field. This IS correct, but makes no sense!
Code:
Code:
function checkQuantity() { var minimumQuantity = document.getElementById("minimumQuantity").innerHTML; if(minimumQuantity != "Not applicable") { var quantityEntered = document.getElementById("qty").value; parseInt(minimumQuantity); parseInt(quantityEntered); if(quantityEntered < minimumQuantity) { alert("The minimum order for this product is "+minimumQuantity+" units.\n\nYou entered "+quantityEntered+". Please correct the quantity and try again."); return false; } } }
Comment