Hello. I am making an order form in which some of the fields need to be 8 or above. I want it so that whenever the user clicks off of the field (after filling in the quantity of the item they want), it checks to see if the value is anywhere from 1 to 8 and if it is, to tell the user that it needs to be 8 or above, set the field's value to 8, and focus on it. The method I tried didn't work. The trick is I want the code to be re-useable so I can have like 16 to 100 items validated in the same way without making custom functions for each one. Dig?

Anyway please take a look at what I've got and make any suggestions if you can. The alert works fine, but we get the error when we try focusing or resetting the value of the field in question.

<script Language="JavaScript">
function Field_Validator(mrFieldName, mrFieldValue){

if (mrFieldValue > 0 & mrFieldValue < 8){
alert("Please note that this item has a minimum quantity of 8.");
theForm.mrFieldName.value = 8;

//return (false);

//return (true);


(in the form

Pasta A: <INPUT type="text" name="pastaA" onBlur='Field_Validator("pastaA", this.value)'>

Pasta B: <INPUT type="text" name="pastaB" onBlur='Field_Validator("pastaB", this.value)'>

(NOTE: I tried using onBlur='Field_Validator(this)' and then calling on the value in the validator function using this.value, this.focus(), etc, but it didn't seem to work for whatever reason.)