// If the length of the element's string is 0 then display helper message
function isNotEmpty(elem, helperMsg){
	if(elem.value.length == 0){
		alert(helperMsg);
		elem.focus();
		return false;
	} else {
		return true;
	}
}

// If the element's string matches the regular expression it is numbers
function isNumeric(elem, helperMsg){
	var numExp = /^[0-9]+$/;
	if(elem.value.match(numExp)){
		return true;
	}else{
		alert(helperMsg);
		elem.focus();
		return false;
	}
}

function formZipValidator(){
	// Make quick references to our fields
	var zipcode = document.getElementById('zipcode');
	
	// Check each input in the order that it appears in the form!
	if(isNumeric(zipcode, "Please enter only numbers for your zip code")){
		if(isNotEmpty(zipcode, "Please enter only numbers for your zip code")){
			return true;
		}
	}
	return false;
}

function formQtyValidator(){
	// Make quick references to our fields
	var qty = document.getElementById('qty');
	
	// Check each input in the order that it appears in the form!
	if(isNumeric(qty, "Please enter only numbers for your quantity")){
		if(isNotEmpty(qty, "Please enter only numbers for your quantity")){
			return true;
		}
	}
	return false;
}

