// JavaScript Validation Functions//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//  ALL LETTERS// If the element's string matches the regular expression it is all letters//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++function isAlphabet(elem, helperMsg){	var alphaExp = /^[a-zA-Z]+$/;	if(elem.value.match(alphaExp)){		return true;	}else{		alert(helperMsg);		elem.focus();		return false;	}}//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//  ALL NUMBERS// If the element's string matches the regular expression it is all NUMBERS//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++// If the element's string matches the regular expression it is all numbersfunction isNumeric(elem, helperMsg){	var numericExpression = /^[0-9]+$/;	if(elem.value.match(numericExpression)){		return true;	}else{		alert(helperMsg);		elem.focus();		return false;	}}//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//  NOT EMPTY//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++// If the length of the element's string is 0 then display helper messagefunction notEmpty(elem, helperMsg){	if(elem.value.length == 0){		alert(helperMsg);		elem.focus(); // set the focus to this input		return false;	}	return true;}//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//  LENGTH RESTRICTION//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++function lengthRestriction(elem, min, max){	var uInput = elem.value;	if(uInput.length >= min && uInput.length <= max){		return true;	}else{		alert("Please enter between " +min+ " and " +max+ " characters");		elem.focus();		return false;	}}//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++// CONFIRM SELECTION MADE BY USER//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++function madeSelection(elem, helperMsg){	if(elem.value == "Please Choose"){		alert(helperMsg);		elem.focus();		return false;	}else{		return true;	}}//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/*  E-MAIL VALIDATION FUNCTIONEvery email is made up for 5 parts:   1. A combination of letters, numbers, periods, hyphens, plus signs, and/or underscores   2. The at symbol @   3. A combination of letters, numbers, hyphens, and/or periods   4. A period   5. The top level domain (com, net, org, us, gov, ...)Valid Examples:    * bobby.jo@filltank.net    * jack+jill@hill.com    * the-stand@steven.king.comInvalid Examples:    * @deleted.net - no characters before the @    * free!dom@bravehe.art - invalid character !    * shoes@need_shining.com - underscores are not allowed in the domain nameThe regular expression to check for all of this is a little overkill and beyond the scope of this tutorial to explain thoroughly. However, test it out and you'll see that it gets the job done.*///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++function emailValidator(elem, helperMsg){	var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;	if(elem.value.match(emailExp)){		return true;	}else{		alert(helperMsg);		elem.focus();		return false;	}}
