

<!--

function isMonetary(str)
{var regEx=/^([0-9])+(\.)?([0-9])*$/ig;return regEx.test(str);}
function isAlphaNumeric(str)
{var regEx=/^[a-zA-Z0-9 ]*$/ig;return regEx.test(str);}
function isAlphaNumericNoSpace(str)
{var regEx=/^[a-zA-Z0-9]*$/ig;return regEx.test(str);}
function isAlphaNumericExtra(str)
{var regEx=/^[a-zA-Z0-9\\{\}(\)\-\,\&\/\\\.\:\n\r\@ ]*$/ig;return regEx.test(str);}
function isUrl(str)
{var regEx=/^[a-zA-Z0-9\(\)\-\,\&\/\\\'\.\:\;\?\%\=\_ ]*$/ig;return regEx.test(str);}
function isAlpha(str)
{var regEx=/^[a-zA-Z ]*$/ig;return regEx.test(str);}
function isPostcode(str)
{var regEx=/^[a-zA-Z]{1,2}[0-9][0-9A-Za-z]{0,1} {0,1}[0-9][A-Za-z]{2}$/ig;return regEx.test(str);}
function isNINumber(str)
{var regEx=/^[a-zA-Z][a-zA-Z][0-9]{0,6}[a-dA-D]$/ig;return regEx.test(str);}
function isAlphaExtra(str)
{var regEx=/^[a-zA-Z\\{\}(\)\-\,\&\/\\\.\:\@  ]*$/ig;return regEx.test(str);}
function isAlphaNoSpace(str)
{var regEx=/^[a-zA-Z]*$/ig;return regEx.test(str);}
function isAlphaWithDot(str)
{var regEx=/^[a-zA-Z\.]*$/ig;return regEx.test(str);}
function isNumeric(str)
{return !isNaN(parseInt(str,10));}
function isDate(str)
{var regEx=/^\d{1,2}\/\d{1,2}\/\d{4}$/ig;return regEx.test(str);}
function isDigits(str)
{var regEx=/^[0-9]*$/ig;return regEx.test(str);}
function isEmail(str)
{
	var regEx=/^[0-9a-zA-Z\@\.\-\_]+$/ig;
	if (str=="@.") return false;
	if (regEx.test(str)) { if (str.indexOf("@")>0) { return true;} }
	return false;
}

function validateParam(inputID,outputID,vtype,minChars,maxChars,minVal,maxVal)
{
	if(document.getElementById(inputID)==null) return true;
	if(document.getElementById(outputID)==null) return true;
	var element=document.getElementById(inputID);
	var input=document.getElementById(inputID).value;
	var valid=true; bCheckChars=true; var bMinChars=true; var bMaxChars=true;
	var msg="";
	var tmpDate;
	
	if(input.length>0)
	{
		switch(vtype.toLowerCase())
		{
			case "none" : bCheckChars=true; break;
			case "numeric" : 
			case "numeric2" : 
				bCheckChars=isNumeric(input);
				if(!bCheckChars) { msg="This field contains an invalid number"; }
				else 
				{ 
					if(parseInt(input) < minVal) { msg="This field must be at least "+minVal; bCheckChars=false; } 
					if(parseInt(input) > maxVal) { msg="This field must be no bigger than "+maxVal; bCheckChars=false; } 
				}
				break;
			case "monetary" :
				bCheckChars=isMonetary(input);
				if(!bCheckChars) { msg="This field contains an invalid value"; }
				break;			
			case "date" :
			case "date2" :
			case "dateofbirth" :
				bCheckChars=isDate(input);
				if(!bCheckChars) { msg="This field contains an invalid date"; }
				break;			
			case "postcode" :
				bCheckChars=isPostcode(input);
				if(!bCheckChars) { msg="This field contains an invalid postcode"; }
				break;
			case "ninumber" :
				bCheckChars=isNINumber(input); if(!bCheckChars) { msg="This field contains an invalid NI number"; }
				break;
			case "digits" : 
				bCheckChars=isDigits(input);
				if(!bCheckChars) { msg="This field contains an invalid digit"; }
				break;
			case "email" :
				bCheckChars=isEmail(input); if(!bCheckChars) { msg="This field contains an invalid email address"; } 
				break;
			case "alphanospace" :
				bCheckChars=isAlphaNospace(input); if(!bCheckChars) { msg="This field contains invalid characters"; } 
				break;
			case "alphawithdot" :
				bCheckChars=isAlphaWithDot(input); if(!bCheckChars) { msg="This field contains invalid characters"; } 
				break;
			case "alpha" :
				bCheckChars=isAlpha(input); if(!bCheckChars) { msg="This field contains invalid characters"; } 
				break;
			case "alphaextra" :
				bCheckChars=isAlphaExtra(input); if(!bCheckChars) { msg="This field contains invalid characters"; } 
				break;
			case "alphanumericnospace" :
				bCheckChars=isAlphaNumericNoSpace(input); if(!bCheckChars) { msg="This field contains invalid characters"; } 
				break;
			case "alphanumeric" :
				bCheckChars=isAlphaNumeric(input); if(!bCheckChars) { msg="This field contains invalid characters"; } 
				break;
			case "alphanumericextra" :
				bCheckChars=isAlphaNumericExtra(input); if(!bCheckChars) { msg="This field contains invalid characters"; } 
				break;
			case "url" :
				bCheckChars=isUrl(input); if(!bCheckChars) { msg="This field contains invalid characters"; } 
				break;
		}
	}

	if((minChars!=-99)&&(input.length<minChars))
	{
		if(msg.length>0) msg+=" and "; else msg+="This field ";
		if(input.length==0) msg+="is required"
		if(element.type.indexOf("select")==-1)
		{
			if(minChars>1)
			{
				if(input.length==0) msg+=" and";
				if(maxChars==-99) { msg+=" must be at least "+minChars+" characters in length"; }
				else
				{
					if(minChars==maxChars) msg+=" must be exactly "+minChars+" characters in length";
					else msg+=" must be between "+minChars+" and "+maxChars+" characters in length";
				}
			}
		}
		bMinChars=false;
	}
	if((maxChars!=-99)&&(input.length>maxChars)&&(element.type.indexOf("select")==-1))
	{
		if(msg.length>0) msg+=" and "; else msg+="This field ";
		if(maxChars==-99) { msg+=" must be no longer than "+maxChars+" characters in length"; }
		{
			if(minChars==maxChars) msg+=" must be exactly "+minChars+" characters in length";
			else msg+=" must be between "+minChars+" and "+maxChars+" characters in length";
		}
		bMaxChars=false;
	}
	
	if (!bCheckChars || !bMinChars || !bMaxChars) { element.style.backgroundColor="#ffefe5"; valid=false; }
	else { element.style.backgroundColor="#FFFFE8"; }
	document.getElementById(outputID).innerHTML=msg;
	document.getElementById(outputID).style.color="#ff0000";
	return valid;
}

-->