//JavaScript
<!--
//Checks to see if the string contains only alaphabet characters
function isAlphaOnly(userInput){
	var str		= userInput;
	var strLen	= str.length;
	var validStr	= "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
	var i		= 0;
	for(i=0; i<strLen; i++){
		if(validStr.match(str.charAt(i)) == null){return true;}	//the string does not contain only numbers
	}
	return false;
}

//Checks to see if the string contains only alaphabet characters and numbers
function isAlphaNumOnly(userInput){
	var str		= userInput;
	var strLen	= str.length;
	var validStr	= "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
	var i		= 0;
	for(i=0; i<strLen; i++){
		if(validStr.match(str.charAt(i)) == null){return true;}	//the string does not contain only numbers
	}
	return false;
}

//Checks to see if the string contains only numbers
function isCustomCharOnly(userInput, charSet){
	var str		= userInput;
	var strLen	= str.length;
	var validStr	= charSet;
	var i		= 0;
	for(i=0; i<strLen; i++){
		if(validStr.match(str.charAt(i)) == null){return true;}	//the string does not contain only numbers
	}
	return false;
}

//Checks to see if the string is a valid e-mail address
function isEmail(userInput){
	var str		= userInput;
	var strLen	= str.length;
	var validStr	= "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ[]-_.";
	var iFirstAt	= str.indexOf("@");
	var iLastDot	= str.lastIndexOf(".");
	var iFlagDot	= 0;
	var i		= 0;
	if(isEmpty(userInput)== false){
		if(iFirstAt < 1){return true;}			//string doesn't contain @ or @ is the first character
		if(iFirstAt > iLastDot){return true;}		//@ must come before the last .
		if(iLastDot == (strLen-1)){return true;}	//. can not be the last character
		for(i=0; i<iFirstAt; i++){
			if(validStr.match(str.charAt(i)) == null){return true;}	//the string does not contain only numbers
			if(".".match(str.charAt(i)) != null){iFlagDot = 1;}
			else{iFlagDot = 0;}
		}
		i++;
		if(".".match(str.charAt(i)) != null){return true;}			//. came right after @
		for( ; i<strLen; i++){
			if(validStr.match(str.charAt(i)) == null){return true;}	//the string does not contain only numbers
		}
		if(iFlagDot == 1){return true;}			//between the . before @ has not characters
	}
	return false;
}

//Checks to see if the string is empty
function isEmpty(userInput){
	var str, strLength;
	str		= userInput.replace(/ /g, "");	//Removes all empty spaces
	strLength	= str.length;
	if((str == null) || (strLength == 0)){	//the userInput is empty
		return true;
	}
	return false;
}

//Checks to see if the all fields are filled if one is filled
function isFillOneFillAll(arrayFieldNames){
	var i			= 0;
	var fieldsFilled	= 0;
	var arrayLength	= arrayFieldNames.length;
	for(i = 0; i < arrayLength; i++){
		if(document.getElementById(arrayFieldNames[i]).value.length > 0){fieldsFilled++;}
	}
	if((fieldsFilled == 0) || (fieldsFilled == arrayLength)){
		return false;		//all or none filleds are filled
	}
	else{
		return true;
	}
}

//Checks to see if the string contains only numbers
function isNumOnly(userInput){
	var str		= userInput;
	var strLen	= str.length;
	var validStr	= "0123456789";
	var i		= 0;
	for(i=0; i<strLen; i++){
		if(validStr.match(str.charAt(i)) == null){return true;}	//the string does not contain only numbers
	}
	return false;
}

//Checks to see if the required quantity is selected
function isSelected(arrayFieldNames, minQuantity){
	var i			= 0;
	var checkQuantity	= 0;
	var arrayLength	= arrayFieldNames.length;
	for(i = 0; i < arrayLength; i++){
		if(document.getElementById(arrayFieldNames[i]).checked){
			checkQuantity++;
			if(checkQuantity == minQuantity){return false;}//the minQuantity has been selected
		}
	}
	return true;
}

//Checks to see if the string has X characters in length
function isXNumLong(userInput, xNum){
	var strLen	= userInput.length;
	if((strLen != xNum) && (strLen > 0)){ return true; }	//the string is not empty and does not have X characters long
	else{ return false; }
}
//-->