<!--
// JavaScript Document
/*
Create the list below in the format
validateList[ <num>]	= ["<field>", "<checkType>", Depends on checkType, see list of checkTypes below];
e.g:
validateList[ 0]	= ["document.formName.fieldName", "isEmpty", "The field is empty, please fill it in"];
validateList[ 1]	= ["document.getElementById('radioEmployedYes')",	"isSelected", 1, "[radioEmployedYes, radioEmployedNo]", "Are you currently employed? Please select yes or no."];
*/

/*List of checkType
<isAlphaOnly>		- Checks if the field contains alphabet char only			- <field>, <checktype>, <Alert Msg>
<isAlphaNumOnly>	- Checks if the field contains alphabet and num char only	- <field>, <checktype>, <Alert Msg>
<isCustomCharOnly>	- Checks if the field contains the Char Set only			- <field>, <checktype>, <Alert Msg>, <Custom Char Set >
<isEmail>			- Checks if e-mail is valid							- <field>, <checktype>, <Alert Msg>
<isEmpty>			- Checks if the field is empty						- <field>, <checktype>, <Alert Msg>
<isFillOneFillAll>	- Checks if the field is all is filled if one filled		- <field>, <checktype>, <Array of fields by id names>, <AlertMsg>
<isNumOnly>		- Checks if the field contains numbers only				- <field>, <checktype>, <Alert Msg>
<isSelected>		- Checks if the field is selected						- <field>, <checktype>, <Required Num Of Selected>, <Array of fields by id names>, <AlertMsg>
<isXCharLong>		- Checks if the field has the X char long				- <field>, <checktype>, <value>, <Alert Msg>

Return this function, add the array list to the argument "theList"
eg. myFunc(){return validateList(myList);}
//*/
function validateList(theList){
	var i			= 0;
	var validateLen	= 0;
	var quantity		= 0;
	var field			= "";
	var checkType		= "";
	var alertMsg		= "";
	var charSet		= "";
	var arrayFieldNames	= new Array();

	validateLen		= theList.length;
	for(i = 0; i < validateLen; i++){		
		field	= eval(theList[i][0]);
		checkType	= theList[i][1];
				
		switch(checkType){
		case 'isAlphaOnly':
			alertMsg	= theList[i][2];
			if(isAlphaOnly(field.value)){
				field.select();
				alert(alertMsg);
				return false;
			}
			break;
		case 'isAlphaNumOnly':
			alertMsg	= theList[i][2];
			if(isAlphaNumOnly(field.value)){
				field.select();
				alert(alertMsg);
				return false;
			}
			break;
		case 'isCustomCharOnly':
			alertMsg	= theList[i][2];
			charSet	= theList[i][3];
			if(isCustomCharOnly(field.value, charSet)){
				field.select();
				alert(alertMsg);
				return false;
			}
			break;
		case 'isEmail':
			alertMsg	= theList[i][2];
			if(isEmail(field.value)){
				field.select();
				alert(alertMsg);
				return false;
			}
			break;
		case 'isEmpty':
			alertMsg	= theList[i][2];
			if(isEmpty(field.value)){
				field.focus();
				alert(alertMsg);
				return false;
			}
			break;
		case 'isFillOneFillAll':
			arrayFieldNames	= theList[i][2];
			alertMsg			= theList[i][3];
			if(isFillOneFillAll(arrayFieldNames)){				
				field.focus();
				alert(alertMsg);
				return false;
			}
			break;
		case 'isNumOnly':
			alertMsg	= theList[i][2];
			if(isNumOnly(field.value)){
				field.select();
				alert(alertMsg);
				return false;
			}
			break;
		case 'isSelected':
			quantity			= theList[i][2];
			arrayFieldNames	= theList[i][3];
			alertMsg			= theList[i][4];
			if(isSelected(arrayFieldNames, quantity)){				
				field.focus();
				alert(alertMsg);
				return false;
			}
			break;
		case 'isXCharLong':
			quantity	= theList[i][2];
			alertMsg	= theList[i][3];
			if(isXNumLong(field.value, quantity)){
				field.select();
				alert(alertMsg);
				return false;
			}
			break;
		}//switch
	}//for
	return true;
}
//-->