Your code looks OK, though a bit more complex than is needed. Basically what you are doing is returning true if the value passes certain tests, and alerting a message while returning false if it does not.
All well and good. But the crucial part is what does your form do with the return value? Part of this would be a result of where this function is called. Pretty much the ideal place would be onsubmit of the form, ex:
Code:
<form action="whatever" onsubmit="return CheckQuantity(this.elements.name_of_the_input);">
form contents
</form>
If you want more help we would need to see the form. Better yet:
Please post a link to the page on your site that contains the problematic code so we can check it out.
Bookmarks