function isNumeric(elem, helperMsg) {
	var numericExpression = /^[0-9]+$/;
	if(elem.value.match(numericExpression)) {
		elem.style.background= '#f2f2f2';
		return true;
	} else {
		alert(helperMsg);
		elem.style.background='#ff9999';
		return false;
	}
}

function checkCheckBox(cb){
	return cb.checked;
}

function CheckboxChecked(elem,helperMsg) {
	if(elem.checked) {
		elem.style.background= '#f2f2f2';
		return true;
	} else {
		alert(helperMsg);
		elem.style.background='#ff9999';
		return false;
	}
}

function isAlphanumeric(elem, helperMsg) {
	var alphaExp = /^[0-9a-zA-Z]+$/;
	if(elem.value.match(alphaExp)) {
		elem.style.background= '#f2f2f2';
		return true;
	} else {
		alert(helperMsg);
		elem.style.background='#ff9999';
		return false;
	}
}

function isAlphabet(elem, helperMsg) {
	var alphaExp = /^[a-zA-Z]+$/;
	if(elem.value.match(alphaExp)) {
		elem.style.backgroundColor = '#f2f2f2';
		return true;
	} else {
		alert(helperMsg);
		elem.style.backgroundColor = '#ff9999';
		return false;
	}
}

function isAlphabet_s(elem, helperMsg) {
	var alphaExp = /^[a-zA-Z ]+$/;
	if(elem.value.match(alphaExp)) {
		elem.style.backgroundColor = '#f2f2f2';
		return true;
	} else {
		alert(helperMsg);
		elem.style.backgroundColor = '#ff9999';
		return false;
	}
}

function isEmpty(elem,helperMsg) {
	if (elem.value.length == 0) {
		alert(helperMsg);
		elem.style.background='#ff9999';
		return false;
    } else {
		elem.style.background= '#f2f2f2';
		return true;
    }
}


function lengthRestriction(elem, min, max) {
	var uInput = elem.value;
	if(uInput.length >= min && uInput.length <= max) {
		elem.style.background= '#f2f2f2';
		return true;
	} else {
		alert("Please enter between " +min+ " and " +max+ " characters");
		elem.focus();
		elem.style.background='#ff9999';
		return false;
	}
}

function validate_email(field) {
	with (field) {
		apos=value.indexOf("@");
		dotpos=value.lastIndexOf(".");
		if (apos<1||dotpos-apos<2) {
			field.style.background = '#ff9999';
			return false;
		} else {
			elem.style.background= '#f2f2f2';
			return true;
		}
	}
}
