
var ErrorCount = 0; /* No of errors */
var ErrorMsg = new Array(); /* A list of all errors */
		
ErrorMsg[0]="------------------------- The Following Errors Occured -------------------------" + String.fromCharCode(10);

/* To validate the type of input values in the form fields */
function CheckFieldString(type, formField, strMsg) {

	var checkOK = false;
	var checkStr = formField.value;
  	var allValid = true;
	var flagDot  = false;
	var namestr, domainstr;
	
	if (type == 'noblank')
	{
		if (checkStr == "")
  		{
  			ErrorCount++;
	   	 	ErrorMsg[ErrorCount] = strMsg  + String.fromCharCode(10);
  		}
	} else 	{
		switch(type)
		{
			case 'integer':
				checkOK = /^[0-9]+$/.test(checkStr);
				break;
			case 'decimal':
				checkOK = /^[0-9]+(\[.,]{1}[0-9]+)?$/.test(checkStr);
				break;
			case 'text':
				checkOK = /^[a-zA-Z]+$/.test(checkStr);
				break;
			case 'alphanumeric':
				checkOK = /^[a-zA-Z0-9-=\[\]_\+\.#, \(\)]+$/.test(checkStr);
				break;
			case 'full':
				checkOK = /^.+$/.test(checkStr);
				break;
			case 'alphanum':
				checkOK = /^[a-zA-Z0-9-_ ]+$/.test(checkStr);
				break;
			case 'email':
				checkOK = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,7})+$/.test(checkStr);
				break;
			case 'phone':
				checkOK = /^[0-9-\+]{8,}$/.test(checkStr);
				break;
			case 'url':
				checkOK = /^http:\/\/[a-zA-Z\.0-9-_]$/.test(checkStr);
				break;
			case 'path':
				checkOK = '/^.+$/'.test(checkStr);
				break;
			default:
				ErrorMsg[1] = "Check Validation one of the mentioned validation type is wrong" + String.fromCharCode(10);
				ErrorCount++;
				return 1;
		}
		
		/* code for email validation */
		/* if ((type == 'email') && (checkStr != "")) {	
			
			namestr = checkStr.substring(0, checkStr.indexOf("@"));  // everything before the '@'
			domainstr = checkStr.substring(checkStr.indexOf("@")+1, checkStr.length); // everything after the '@'

			// Rules: namestr cannot be empty, or that would indicate no characters before the '@',
			// domainstr must contain a period that is not the first character (i.e. right after
			// the '@').  The last character must be an alpha.
   			if ((namestr.length == 0) || (domainstr.indexOf(".") <= 0) || (domainstr.indexOf("@") != -1)) {
   				ErrorCount++;
				ErrorMsg[ErrorCount] = "Enter a valid Email Address." + String.fromCharCode(10);
   			} 
		} */		

		if(! checkOK)
		{
			ErrorCount++;
			ErrorMsg[ErrorCount] = strMsg  + String.fromCharCode(10);
		}
  	}
}

