Hey guys!

Can anyone spot an error that I'm overlooking in the code below? The original formAction() function worked fine, until I added the validation sequence...

Code:
function formAction(SubmitType,ProdID,OptionNum,OptionPrice){
		if (ValidatePage()){
			document.forms[0].submitType.value = SubmitType;
			document.forms[0].itemInQuestion.value = ProdID;
			document.forms[0].OptionNumber.value = OptionNum;
			document.forms[0].OptionPrice.value = OptionPrice;
			document.forms[0].submit();
		}
	}
	
	function ValidatePage(){
		Validated = true;
		
		for (i=0;i<document.forms[0].elements.length;i++) {
			fieldName = document.forms[0].elements[i].name;
			fieldValue = document.forms[0].elements[i].value;
			if (!fieldName.match('Quantity') == null) {
				document.forms[0].elements[i].value = fieldValue.replace(',', ''); //make sure there are no commas in the number
				
				if (isNaN(fieldValue)) {
    				ItemIDNumber = fieldName.replace('Quantity', ''); //leaves only the ID Number
    				document.forms[0].elements[i].focus();
    				document.forms[0].elements[i].select();
    				ErrorCounter += 1;
    				LastErrorID = ItemIDNumber;
    				stringOfErrors += '\t&middot; ' + ItemIDNumber + '\n';
    				Validated = false;
    			}
			}
		}
		
		if (Validated){
			return true;
		}else{
			if (ErrorCounter > 1){
				finalErrorString = 'The following products\' quantities are not valid numbers:\n\n';
				finalErrorString += stringOfErrors + '\n';
				finalErrorString += 'Please enter numeric values and try again.';
			}else{
				finalErrorString = 'The quantity for product ' + LastErrorID + ' is not a valid number.\n\n';
				finalErrorString += 'Please enter a numeric value and try again.';
			}
			alert(finalErrorString);
			
			return false;
		}
	}
Thanks for any help!

Brandon