/**
 * Only allow numeric input
 * 
 * @param	string	str		The string as entered by the user.
 * @return					Cleaned-up string.
 */
function numericInput(str) {
	str = str.toUpperCase();
	str = str.replace(/[^0-9\.]/g,'');
	return str;
}

/**
 * Determine if a string conforms to standard email address format
 * 
 * @param	string	email		The string to validate.
 * @return						Boolean value.
 */
function validEmail(email) {
	// Email cannot be null or empty
	if (!email || email == "") {
		return false;
	}
	// Email address must be at least 5 characters long
	else if (email.length < 5) {
		return false;
	}
	// Spaces and commas are explicitly disallowed (other disallowed characters are not checked)
	else if (email.indexOf(" ") > -1 || email.indexOf(",") > -1) {
		return false;
	}
	// @ must appear once and be in at least the second position
	else if (email.indexOf("@") != email.lastIndexOf("@") || email.indexOf("@") < 1) {
		return false;
	}
	// . must appear at least 1 character after @ and must be at least 2 characters from end
	else if (email.lastIndexOf(".") <= (email.lastIndexOf("@") + 1) || email.lastIndexOf(".") > email.length - 2) {
		return false;
	}
	else {
		return true;
	}
}
