//***** VALIDATION *****//
function removeSpaces(s) {
	var string = s;
	string = string.replace(/ /g, "");
	return string;
}

function validateInput(string, type, maxlength) {
	var isValid = true;

	// perform type-specific validation
	switch (type) {
		case "string":
			if (removeSpaces(string).length < 1 || removeSpaces(string) == null)
				isValid = false;
			break;
			
		case "email":
			var emailReg = /^([a-zA-Z0-9])+([\.a-zA-Z0-9_-])*@([a-zA-Z0-9])+(\.[a-zA-Z0-9_-]+)+$/;
			if (!string.match(emailReg))
				isValid = false;
			break;
			
		default:
			isValid = false;
	}
	
	// check if string is longer than maxlength
	if (string.length > maxlength)
		isValid = false;
		

	// return true or false
	if (isValid)
		return true;
	else
		return false;
}

