// validate.js
// alerts user if the entry field is incorrect
function validFloat(field) {
	var val    = field.value;
	var newVal = "";
	var aChar  = '';

	if (val.length == 0) {
		field.style.backgroundColor="white";
		return; // empty field - ignore it
	}

	for (var i = 0; i < val.length; i++) {
		// strip spaces from begging/end of string
		aChar = val.charAt(i);
		if (val.charAt(i) != ' ')
			newVal = newVal + aChar;
	}
	field.value = newVal;
	if (!validateDouble(field)) {
		alert('Make sure the entry you have\nmade is a floating point number!');
		field.style.backgroundColor="red";
		field.focus();
	} else {
		field.style.backgroundColor="white";
	}
}

// alerts user if the entry field is incorrect
function validInt(field) {
	var val    = field.value;
	var newVal = "";
	var aChar  = '';

	if (val.length == 0) {
		field.style.backgroundColor="white";
		return; // empty field - ignore it
	}

	for (var i = 0; i < val.length; i++) {
		// strip spaces from begging/end of string
		aChar = val.charAt(i);
		if (val.charAt(i) != ' ')
			newVal = newVal + aChar;
	}
	field.value = newVal;
	if (!validateInteger(field)) {
		alert('Make sure the entry you have\nmade is an integer number!');
		field.style.backgroundColor="red";
		field.focus();
	} else {
		field.style.backgroundColor="white";
	}
}

