My site sells chairs, some of which are only sold in cartons (usually 4 chairs, but sometimes more or less). Currently I have them sold by the carton, so that customers can not try to order just 1 chair. I want to sell them individually, but validate the quantity box to make sure it is a number divisible by 4, but this is way beyond my skills.
Here’s the important part of the form, I’m leaving out irrelevant stuff:
[code=php]
<FORM method=”post” action=”http://www.ewebcart.com/cgi-bin/cart.pl” name=orders >
Quantity:
<INPUT type=”text” name=”quantity” value=”1″ maxlength=”3″ size=”1″>
<INPUT type=”image” src=”add.gif” name=”add” border=”0″ class=add
onClick=”return validateFurniture();”>
</FORM>
As you can see, there is already some validation on this script (checks to see if they clicked a checkbox). That part works fine, so I’ve not included it in this post. I need some way to check the quantity box on submit, divide it by a number (usually 4, but not always) and see if the result is a whole number. If not, return false and give them an error message.