function validateQty(f, defaultValue, strictness) {
	// f is the form. defaultValue: 0=quantity required, 1=default to quantity of one.
	// strictness: 0=positive integers only, 1=positive decimals okay.
	// Stop and notify on first error. If quantities required and none given, notify after checking all.
	var firsterr = -1;
	var result = 0;
	var goodCount = 0;
	// Loop through all submitted elements.
	for(var i = 0; i < f.length; i++) {
		var e = f.elements[i];
		// Deal with elements starting with quant.
		if (e.name.substring(0, 5) == "quant") {
			// Remove leading and trailing whitespace.
			var n = trim(e.value);
			// Check for all types of "empty" fields, when a number is required.
			if ( (defaultValue < 1) && ((n == null) || (n == "") || (isBlank(n))) ) {
				if (firsterr == -1) firsterr = i;
			// Check for value of zero, when a number is required.
			} else if ((defaultValue < 1) && (n == 0)) {
				if (firsterr == -1) firsterr = i;
			// Check for non-numeric data.
			} else {
				// Integers only.
				if (strictness == 0) {
					result = n.match(/[^0-9]/);
					if (result != null) {
						alert("The quantity you entered (" + n + ") is not valid. Please enter a whole number quantity,\nusing only the digits 0 through 9.");
						e.focus();
						e.select();
						return false;
					} else {
						// Check essential quantities. Inessential quantity fields should begin with something less than 'quantity', like 'quant_'.
						if (e.name.substring(0, 8) == "quantity") {
							if (e.type == 'checkbox') {
								if (e.checked) goodCount++;
							} else {
								goodCount++;
							}
						}
					}
				// Decimals okay.
				} else if (strictness == 1) {
					result = n.match(/[^0-9\.]/);
					if (result != null) {
						alert("The quantity you entered (" + n + ") is not valid. Please enter a numeric quantity,\nusing only the digits 0 through 9 and a decimal point, if required.");
						e.focus();
						e.select();
						return false;
					} else {
						// Check essential quantities. Inessential quantity fields should begin with something less than 'quantity', like 'quant_'.
						if (e.name.substring(0, 8) == "quantity") {
							if (e.type == 'checkbox') {
								if (e.checked) goodCount++;
							} else {
								goodCount++;
							}
						}
					}
				}
			}
		}
	}
	// All is good, continue on.
	if ((defaultValue == 1) || (goodCount > 0)) return true;
	// If all blank and a quantity was required, select first quantity input and notify.
	alert("Please enter a quantity.");
	if (firsterr != -1) {
		f.elements[firsterr].focus();
		f.elements[firsterr].select();
	}
	return false;
}

