View Full Version : Min / Max Quantity form code - limit range of values

10-30-2005, 10:07 PM
Hi All

I need to have some way to control the range of minimum and maximum quantities allowed in an order form

The script itself should be kinda generic such that I can call it remotely on all order pages, but then in the form code, I could specify the min/max for any particular item. It also needs to work with type=submit, not type=button:


I found the following over at CodingForums.com, but (1) it only has the header code, not the form code and (2) I'm not sure if it will do what I need:

<SCRIPT TYPE="text/javascript">
function valuevalidation(entered, min, max, alertbox, datatype)
with (entered)
if (datatype)
if (smalldatatype.charAt(0)=="i") {checkvalue=parseInt(value)};
if ((parseFloat(min)==min && checkvalue<min) || (parseFloat(max)==max && checkvalue>max) || value!=checkvalue )
{if (alertbox!="") {alert(alertbox);} return false;}
else {return true;}

Would anyone know if this would work and how to complete the total script to include the form code, too?

Many thanks :)