
// function to validate a Person Name
// allows alphabets, Space, '.' only
function Emailcheck(str)
 {
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)


		 if(str.length != 0) 
		{ 
			var count = 0 ;
			for(i=0; i<str.length; i++)
			{	
				if(str.charAt(i)==".")
			    {
			    count = count+1;
			    if(count == 2)
				{					
					alert("Invalid E-mail ID")
					document.getElementById("txtEmail").focus();
					return false;					
				}
			  }
			}
		}

		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID")
		   return false;
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false;
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false;
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false;
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false;
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false;
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false;
		 }
		

 		 return true;					
	}
function ValidateName(input,control,compulsory)
{
	var Cont_Value = input;
	var Cont_Name =control;
	var Cont_Validate=compulsory;
	var len;

	if ((Cont_Validate=="Y") && (Cont_Value.length==0))
	{
		alert (Cont_Name + " is left blank. You have to fill-in this field.");
		return false;
	}
	else if (Cont_Value.charAt(0)==" ")
	{
		alert (Cont_Name + " does not allow a data with first character as a blank character. Please re-enter the data.")
		return false
	}
	/*else if ((Cont_Value.charAt(0)==" "))
	{
		alert (Cont_Name + " does not allow a data with first character as a blank character. Please re-enter the data.")
		return false
	}*/
	else if((Cont_Value.charCodeAt(0)==1586))
	{
		alert("First character of " + Cont_Name + " cannot be a dot. Please re-enter the data.");
		return false;
	}
	else if(Cont_Value!="")
	{
		len = Cont_Value.length;
		for(i = 0; i < len; i++)
		{
			if((Cont_Value.charCodeAt(i) >= 65 && Cont_Value.charCodeAt(i) <= 122)|| (Cont_Value.charCodeAt(i) >= 47 && Cont_Value.charCodeAt(i)<= 58) ||  (str=="'"))
			{
				alert ("Please enter alphabets only in " + Cont_Name+".");
				return false;
			}
	    }
	}
	else
		return true;		
}



//Arabic address validation
// allows alphabets, Space, '.', 1-9 only
function ValidateArabicAddress(input,control,compulsory)
{
	var Cont_Value = input;
	var Cont_Name =control;
	var Cont_Validate=compulsory;
	var len;

	if ((Cont_Validate=="Y") && (Cont_Value.length==0))
	{
		alert (Cont_Name + " is left blank. Please fill-in this field.");
		return false;
	}
	else if (Cont_Value.charAt(0)==" ")
	{
		alert (Cont_Name + " does not allow a data with first character as a blank character. Please re-enter the data.")
		return false
	}
/*	else if ((Cont_Value.charAt(0)==" "))
	{
		alert (Cont_Name + " does not allow a data with first character as a blank character. Please re-enter the data.")
		return false
	}*/
	else if((Cont_Value.charCodeAt(0)==1586))
	{
		alert("First character of " + Cont_Name + " cannot be a dot. Please re-enter the data.");
		return false;
	}
	else if(Cont_Value!=""){
		len = Cont_Value.length;
		for(i = 0; i < len; i++){
			if((Cont_Value.charCodeAt(i) > 65 && Cont_Value.charCodeAt(i) < 122)){
				alert ("Please enter arabic characters only in " + Cont_Name+".");
				return false;
			}
	    }
	}
	else
		return true;		
}


function ValidatePersonName(input,control,compulsory)
{
	var Cont_Value = input;
	var Cont_Name =control;
	var Cont_Validate=compulsory;
	
	if ((Cont_Validate=="Y") && (Cont_Value.length==0))
	{
		alert (Cont_Name + " is left blank. Please fill-in this field.");
		return false;
	}
	else if ((Cont_Validate=="Y") &&(Cont_Value.charAt(0)==" "))
	{
		alert (Cont_Name + " does not allow a data with first character as a blank character. Please re-enter the data.")
		return false
	}
	else if ((Cont_Value.charAt(0)==" "))
	{
		alert (Cont_Name + " does not allow a data with first character as a blank character. Please re-enter the data.")
		return false
	}
	else if((Cont_Value.charAt(0)=="."))
	{
		alert("First character of " + Cont_Name + " cannot be a dot. Please re-enter the data.");
		return false;
	}
	else if (!isName(Cont_Value)){
		
		alert ("Only alphabets, space and [.',] are allowed in " + Cont_Name  + ". Re-enter only these characters.");
		return false;	
	}	
	else
		return true;
}


//Validation only for numbers
function ValidateShowRecords(input,control,compulsory)
{
		var Cont_Value = input;
	var Cont_Name =control;
	var Cont_Validate=compulsory;
	
	if ((Cont_Validate=="Y") &&(Cont_Value.length==0))
	{
		alert (Cont_Name + " is left blank. Please fill-in this field.")
		return false
	}	
	else if ((Cont_Validate=="Y") &&(Cont_Value.charAt(0)==" "))
	{
		alert("Only numbers are allowed in the " + Cont_Name + ". Please re-enter valid numbers in this field.")	
		return false
	}
	else if ((Cont_Value.charAt(0)==" "))
	{
	alert("Only numbers are allowed in the " + Cont_Name + " Please re-enter valid numbers in this field.")
		return false
	}
	else if((Cont_Value.charAt(0)=="+") || (Cont_Value.charAt(0)=="-"))
	{
	alert("Only numbers are allowed in the " + Cont_Name + " Please re-enter valid numbers in this field.")

		return false;
	} 
	else if (Cont_Value!="")
	{
		if(Cont_Value <= 0 ) 
		{
		alert("Only numbers are allowed in the " + Cont_Name + " Please re-enter valid numbers in this field.")
			return false;
		}

		for(i=0;i<Cont_Value.length;i++)
		{
			var str=Cont_Value.charAt(i)
			if (!(str >= 0 && str <=9) || str==" ")
			{	
			alert("Only numbers are allowed in the " + Cont_Name + " Please re-enter valid numbers in this field.")

				return false
			}
		}
	}
	else
		return true;
}


function isAddress(val)
{

	var re=/([^A-Za-z0-9._\-\)\(\\,; ])/;
	
	return !re.test(val);
}


function isNumeric(val)
{

	var re=/[^0-9]/;
	return !re.test(val);
}
function isName(val)
{
	var re=/[^A-Za-z.,' ]/;
	return !re.test(val);
}


function isPin(val){
	var re=/[^0-9]/;
	return !re.test(val);
}


function isSSID(val){
	var re=/[^0-9]/;
	return !re.test(val);
}


	
//function to validate pincode
function ValidatePinCode(input, control, compulsory)
{
	var Cont_Value = input;
	var Cont_Name =control;
	var Cont_Validate=compulsory;
	
	if ((Cont_Value=="") && (Cont_Validate=="Y"))
	{
		alert (Cont_Name + " is left blank. Please fill-in this field.")
		return false;
	}
	else if ((Cont_Validate=="Y") &&(Cont_Value.charAt(0)==" "))
	{
	alert (Cont_Name + " does not allow a data with first character as a blank character. Please re-enter the data.")
		return false
	}
	else if ((Cont_Value.charAt(0)==" "))
	{
	alert (Cont_Name + " does not allow a data with first character as a blank character. Please re-enter the data.")
		return false
	}
	//else if ((Cont_Value.charAt(0)=="0"))
	//{
	//alert (Cont_Name + " does not allow a data with first character as a Zero. Please re-enter the data.")
	//return false
	//}
	else if(!isPin(Cont_Value))
	{
		alert("Please enter a valid Pin/Zip code(eg. 55555).");
		return false;
	}	
	else if((Cont_Value!="") && (Cont_Value.length != 5))
	{
			alert("Please enter a valid Pin/Zip code(eg. 55555).");
			return false;		
	}
	else if(Cont_Value.length==5)
		{
			var count = 0 ;
			for(i=0; i<5; i++)
				{	
					if(Cont_Value.charAt(i)=="0")
						{
							count = count+1;
							if(count == 5)
							{	
								alert("Please enter a valid Zip code(eg. 55555).");								
								return false;					
							}
						}
				}
		
		}
	
	else
		return true;
}
	

// function to check house number
function ValidateHouseNumber(input,control,compulsory)
{
	
	var Cont_Value = input;
	var Cont_Name =control;
	var Cont_Validate=compulsory;
	
	if ((Cont_Value=="") && (Cont_Validate=="Y"))
	{
		alert (Cont_Name + " is left blank. Please fill-in this field.");
		return false;
	}
	else if ((Cont_Validate=="Y") &&(Cont_Value.charAt(0)==" "))
	{
		alert (Cont_Name + " does not allow a data with first character as a blank character. Please re-enter the data.");
		return false;
	}
	else if ((Cont_Value.charAt(0)==" "))
	{
		alert (Cont_Name + " does not allow a data with first character as a blank character. Please re-enter the data.")
		return false
	}
	else if((Cont_Value.charAt(0)=="/") || (Cont_Value.charAt(0)=="-") || (Cont_Value.charAt(0)=="\\"))
	{
		alert ("First character of " + Cont_Name + " should be a number. Please re-enter the data.");
		return false;
	}
	else if(!isHouseNumber(Cont_Value))
	{
	
		alert("For " + Cont_Name + " the value " + Cont_Value +  " is not a valid house number. Please re-enter the data.(eg. 1-2-3/1/A)");
		return false;
	}
	else 
		return true;
}

/*function isHouseNumber(val){

var re=/(^[^0-9])|([^A-Za-z0-9:/-])|(:\/)|(\/:)|(-:)|(:-)|(-\/)|(\/-)|(:{2,})|(\/{2,})|(-{2,})/;
	
return !re.test(val);

}*/




function ValidateTextArea(input, control, compulsory,fieldlen)
{
	
	var Cont_Value = input;
	var Cont_Name =control;
	var Cont_Validate=compulsory;
	var Cont_Length=fieldlen;
	var i;
	if ((Cont_Value=="") && (Cont_Validate=="Y"))
	{
		alert (Cont_Name + " is left blank. Please fill-in this field.")
		return false;
	}
	else if ((Cont_Validate=="Y") && ((Cont_Value.charAt(0)==" ") || (Cont_Value.charCodeAt(0)=="13") || (Cont_Value.charCodeAt(0)=="32") ))
	{
		alert (Cont_Name + " does not allow a data with first character as a blank or a new line character. Please re-enter the data.")
		return false
	}
	else if ((Cont_Value.charAt(0)==" "))
	{
		alert (Cont_Name + " does not allow a data with first character as a blank character. Please re-enter the data.")
		return false
	}
	else if (Cont_Value.length > Cont_Length)
	{
		alert (Cont_Name + " Field Length Cannot be greater than " + Cont_Length + " Characters. Please enter data less than or equal to " + Cont_Length + "  characters.");
		return false;
	}
		 if (Cont_Value!="")
	{
		for(i=0;i<Cont_Value.length;i++)
		{
			var str=Cont_Value.charAt(i);
			if (!((str >= 'A' && str <= 'Z' ) || (str >= 'a' && str <= 'z') || (str == ' ') || (str >= 0 && str <=9)|| (str=='.')  || (str==';')  || (str==':')  ||  (str=='*')  ||(str=='!')  || (str=='%')|| (str==',')||(str=='_')||(str=='@') || (str=='#')|| (str=='&')|| (str=='/') || (str=='\\') || (str=='-')|| (str=='+')  ||  (str==")") ||  (str=="(")  ||  (str=="?") ||  (str=="'") || (str=="$") ||(str=='\\n')))
			{	
				alert ("Only alphabets, integers and special characters ( , ! . : ; * $ () - @ # / \\& _ ' + % ?)  are allowed in  " + Cont_Name + ". Please re-enter correct data.")
				return false;
			}
		}
	}
	
else
		return true;	
}


//function to check SSID
function ValidateSSID(input, control, compulsory)
{
	var Cont_Value = input;
	var Cont_Name =control;
	var Cont_Validate=compulsory;
	
	if ((Cont_Value=="") && (Cont_Validate=="Y"))
	{
		alert (Cont_Name + " is left blank. Please fill-in this field.")
		return false;
	}
	else if ((Cont_Validate=="Y") &&(Cont_Value.charAt(0)==" "))
	{
		alert (Cont_Name + " does not allow a data with first character as a blank character. Please re-enter the data.")
		return false
	}
	else if ((Cont_Value.charAt(0)==" "))
	{
		alert (Cont_Name + " does not allow a data with first character as a blank character. Please re-enter the data.")
		return false
	}
	else if(!isSSID(Cont_Value))
	{
		alert( Cont_Name + " should be a 16 digit number. Please re-enter a valid 16 digit SSID");
		return false;
	}	
	else if((Cont_Value!="") && (Cont_Value.length != 16))
	{
			alert( Cont_Name + " should be a 16 digit number. Please re-enter a valid 16 digit SSID");
			return false;			
	}
	else
		return true;
}


function ValidateAddress(input, control, compulsory)
{
	var Cont_Value = input;
	var Cont_Name =control;
	var Cont_Validate=compulsory;
	
	if ((Cont_Value=="") && (Cont_Validate=="Y"))
	{
		alert (Cont_Name + " is left blank. Please fill-in this field.");
		return false;
	}
	else if ((Cont_Validate=="Y") &&(Cont_Value.charAt(0)==" "))
	{
		alert (Cont_Name + " does not allow a data with first character as a blank character. Please re-enter the data.")
		return false
	}
	else if ((Cont_Value.charAt(0)==" "))
	{
		alert (Cont_Name + " does not allow a data with first character as a blank character. Please re-enter the data.")
		return false
	}
	else if((Cont_Value.charAt(0)==".") ||(Cont_Value.charAt(0)=="-") || (Cont_Value.charAt(0)=="/") || (Cont_Value.charAt(0)=="(") || (Cont_Value.charAt(0)==")") || (Cont_Value.charAt(0)==",") || (Cont_Value.charAt(0)==":") || (Cont_Value.charAt(0)=="\\"))
	{
		alert("First character of " + Cont_Name + " cannot be a '.' , '-' , '/' , '(' , ')' , ',' , ':' , '\\'. Please re-enter the data.")
		return false;
	}
	else if(!isAddress(Cont_Value))
	{
		alert("Only alphabets, positive integers and special characters (. , - , ( , ) , comma , : , \\ , / )  are allowed in Address. Please enter valid data in " + Cont_Name);		
		return false;
	}
	else 
		return true;
}


// function to validate person height

function ValidatePersonHeight(input, control, compulsory)
{
	var Cont_Value = input;
	var Cont_Name =control;
	var Cont_Validate=compulsory;

	if ((Cont_Value=="") && (Cont_Validate=="Y"))
	{
		alert(Cont_Name + " is left blank. Please fill-in this field");
		return false;
	}
	else if ((Cont_Validate=="Y") &&(Cont_Value.charAt(0)==" "))
	{
		alert (Cont_Name + " does not allow a data with first character as a blank character. Please re-enter the data.")
		return false
	}
	else if ((Cont_Value.charAt(0)==" "))
	{
		alert (Cont_Name + " does not allow a data with first character as a blank character. Please re-enter the data.")
		return false
	}
	else if(isNaN(Cont_Value))
	{
		alert("Please enter valid data in " + Cont_Name + ".");
		return false;
	}
	else if((Cont_Value.charAt(0)=="+") || (Cont_Value.charAt(0)=="-"))
	{
		alert("Arithmetic characters are not allowed in " + Cont_Name + ". Please remove the arithmetic character and re-enter the data.")
		return false;
	}
	else if ((Cont_Value < 1) && (Cont_Value!=""))
	{
		
		alert("Please enter valid data in " + Cont_Name);
		return false;
	}
	else if(validateTwoDigits(input, control, compulsory)==false)
	{
		alert(Cont_Name + " allows only 2 digits after decimal (eg. 45.45) Please re-enter correct data");
		return false;
	}	
	else if(parseInt(Cont_Value) > 250)
	{
		alert(Cont_Name + " allows only between 1 and 250. Please re-enter correct data");
		return false;
	}
	else 
		return true;
	
}


// function to validate person Weight

function ValidatePersonWeight(input, control, compulsory)
{
	var Cont_Value = input;
	var Cont_Name =control;
	var Cont_Validate=compulsory;

	if ((Cont_Value=="") && (Cont_Validate=="Y"))
	{
		alert (Cont_Name + " is left blank. Please fill-in this field.")
		return false;
	}
	else if ((Cont_Validate=="Y") &&(Cont_Value.charAt(0)==" "))
	{
		alert (Cont_Name + " does not allow a data with first character as a blank character. Please re-enter the data.")
		return false
	}
	else if ((Cont_Value.charAt(0)==" "))
	{
		alert (Cont_Name + " does not allow a data with first character as a blank character. Please re-enter the data.")
		return false
	}
	else if(isNaN(Cont_Value))
	{
		alert("Only valid number between 1 and 1000 is allowed in " + Cont_Name + " (eg. 45.45) Please re-enter correct data");
		return false;
	}
	else if((Cont_Value.charAt(0)=="+") || (Cont_Value.charAt(0)=="-"))
	{
		alert("Arithmetic characters are not allowed in " + Cont_Name + ". Please remove the arithmetic character and re-enter the data.")
		return false;
	}
	else if ((Cont_Value<1) && (Cont_Value!=""))
	{
		alert("Only valid number between 1 and 1000 is allowed in " + Cont_Name + " (eg. 45.45) Please re-enter correct data");
		return false;
	}	
	
	else if(validateTwoDigits(input, control, compulsory)==false)
	{
		alert(Cont_Name + " allows only 2 digits after decimal (eg. 45.45) Please re-enter correct data");
		return false;
	}
	else if(parseInt(Cont_Value) > 1000)
	{
		alert("Please enter valid weight of a person (in Kilograms) in  " + Cont_Name);
		return false;
	}
	else 
		return true;	
}


function ValidateTemperature(input, control, compulsory)
{
	
	var Cont_Value = input;
	var Cont_Name =control;
	var Cont_Validate=compulsory;

	if ((Cont_Value=="") && (Cont_Validate=="Y"))
	{
		alert (Cont_Name + " is left blank. Please fill-in this field.")
		return false;
	}
	else if ((Cont_Validate=="Y") &&(Cont_Value.charAt(0)==" "))
	{
		alert (Cont_Name + " does not allow a data with first character as a blank character. Please re-enter the data.");
		return false;
	}
	else if ((Cont_Value.charAt(0)==" "))
	{
		alert (Cont_Name + " does not allow a data with first character as a blank character. Please re-enter the data.")
		return false
	}
	else if(isNaN(Cont_Value))
	{
		alert("Please enter a valid temperature value in " + Cont_Name + ".");
		return false;
	}
	else if((Cont_Value.charAt(0)=="+") || (Cont_Value.charAt(0)=="-"))
	{
		alert("Arithmetic characters are not allowed in " + Cont_Name + ". Please remove the arithmetic character and re-enter the data.")
		return false;
	}
	else if(validateTwoDigits(input, control, compulsory)==false)
	{
		alert(Cont_Name + " allows only 2 digits after decimal (eg. 45.45) Please re-enter correct data");
		return false;
	}
	else 
		return true;
}

function validateTwoDigits(input, control, compulsory)
{ 
	var Cont_Value = input;
	var Cont_Name =control;
	var Cont_Validate=compulsory;
	
	
		
		for(i=0;i<Cont_Value.length;i++)
		{
			var str=Cont_Value.charAt(i);
			if ((str=="."))
			{
				if((Cont_Value.length - (i+1)) > 2)
				{
				
					return false;
				}		
			}
		}
	}

// function to validate integers

function ValidateIntegers(input, control, compulsory)
{

	
	var Cont_Value = input;
	var Cont_Name =control;
	var Cont_Validate=compulsory;
	for(i=0;i<Cont_Value.length;i++)
	{
		var str=Cont_Value.charAt(i);
		if(isNaN(str))
		{
		
			alert("Only positive integers (eg. 777) less than 65536 are allowed in " + Cont_Name + ". Negative integer values are not allowed. Please re-enter correct data.");
			return false;
		}
	}
	if ((Cont_Value=="") && (Cont_Validate=="Y"))
	{
		alert (Cont_Name + " is left blank. Please fill-in this field.")
		return false;
	}
	else if ((Cont_Validate=="Y") &&(Cont_Value.charAt(0)==" "))
	{
		alert (Cont_Name + " does not allow a data with first character as a blank character. Please re-enter the data.");
		return false;
	}
	else if ((Cont_Value.charAt(0)==" "))
	{
		alert (Cont_Name + " does not allow a data with first character as a blank character. Please re-enter the data.")
		return false
	}
	else if(isNumeric(Cont_Value)==false)
	{
		alert("Please enter a valid Integer value in " + Cont_Name + ".")
		return false;
	}
	else if((Cont_Value.charAt(0)=="+") || (Cont_Value.charAt(0)=="-"))
	{
		alert("Arithmetic characters are not allowed in " + Cont_Name + ". Please remove the arithmetic character and re-enter the data.")
		return false;
	}
	else if((parseInt(Cont_Value) < 0) || parseInt(Cont_Value) > 65536)
	{
		alert("Only positive integers (eg. 777) less than 65536 are allowed in " + Cont_Name + ". Negative integer values are not allowed. Please re-enter correct data.");
		return false;
	}
	else
		return true;	
}




//function to validate person age less than zero

function ValidatePersonAge(input, control, compulsory)
{
	var Cont_Value = input;
	var Cont_Name =control;
	var Cont_Validate=compulsory;
	for(i=0;i<Cont_Value.length;i++)
	{
		var str=Cont_Value.charAt(i);
		if(isNaN(str))
		{
			alert("Only positive integers (eg. 44) are allowed in " + Cont_Name + ". Negative numbers or zero values are not allowed. Please re-enter correct data.");
			return false;
		}
	}
	if ((Cont_Value=="") && (Cont_Validate=="Y"))
	{
		alert (Cont_Name + " is left blank. Please fill-in this field.")
		return false;
	}
	else if ((Cont_Validate=="Y") &&(Cont_Value.charAt(0)==" "))
	{
		alert (Cont_Name + " does not allow a data with first character as a blank character. Please re-enter the data.");
		return false;
	}
	else if ((Cont_Value.charAt(0)==" "))
	{
		alert (Cont_Name + " does not allow a data with first character as a blank character. Please re-enter the data.")
		return false
	}
	else if ((isNumeric(Cont_Value)==false)&&(Cont_Validate=="Y"))
	{
		alert("Please enter a valid integer number between 1 and 100 in" + Cont_Name + ".");
		return false;
	}
	else if((Cont_Value.charAt(0)=="+") || (Cont_Value.charAt(0)=="-"))
	{
		alert("Arithmetic characters are not allowed in " + Cont_Name + ". Please remove the arithmetic character and re-enter the data.")
		return false;
	}	
	else if(((Cont_Value < 1 ) || (Cont_Value > 100))&&(Cont_Validate=="Y"))
	{
		alert("Only positive integers between 1 and 100 are allowed in " + Cont_Name + ". Please re-enter correct data.");
		return false;
	}
	else
		return true;	
}



function ValidateNoNZero(input, control, compulsory)
{

	var Cont_Value = input;
	var Cont_Name =control;
	var Cont_Validate=compulsory;
	
	if ((Cont_Value=="") && (Cont_Validate=="Y"))
	{
		alert (Cont_Name + " is left blank. Please fill-in this field.")
		return false;
	}
	else if ((Cont_Validate=="Y") &&(Cont_Value.charAt(0)==" "))
	{
		alert (Cont_Name + " does not allow a data with first character as a blank character. Please re-enter the data.");
		return false;
	}
	else if ((Cont_Value.charAt(0)==" "))
	{
		alert (Cont_Name + " does not allow a data with first character as a blank character. Please re-enter the data.")
		return false
	}
	else if ((Cont_Value.charAt(0)==0) && (Cont_Value!=""))
	{
		alert (Cont_Name + " does not allow a data with first character as a '0' character. Please re-enter the data.");
		return false;
	}
	else if(isPin(Cont_Value)==false)
	{
		alert (Cont_Name + " allows only digits and there cannot be any blank spaces or characters between digits. Please re-enter the data.");
		return false;
	}
	else if((Cont_Value.charAt(0)=="+") || (Cont_Value.charAt(0)=="-"))
	{
		alert("Arithmetic characters are not allowed in " + Cont_Name + ". Please remove the arithmetic character and re-enter the data.")
		return false;
	}
	else
		return true;
}

// function to validate date in "mm/dd/yyyy" format and allows year from 1900 to current running year
 
function ValidateCurrentDate(input,control,compulsory)
{
        var Cont_Value = input;
        var Cont_Name =control;
        var Cont_Validate=compulsory;
        var date = new Date();
        if ((Cont_Validate=="Y") &&(Cont_Value.length==0))
        {
                alert (Cont_Name + " is left blank. Please fill-in this field.")
                return false;
        }
        else if (Cont_Value!="")
        {
	
                var strdate=Cont_Value
                var intstart=0
                var intsep=0
                var intcount=0
                var intdate=new Array(2)
                //alert(strdate.lastIndexOf("/"))
                var parts=Cont_Value.split("/");
                if (parts.length>3)
					{
					alert("The Entered Date is Not in Proper Format ");
					return false;
					}
				if ((strdate.indexOf("/",intstart)==-1)||(strdate.indexOf("/",intstart)==strdate.lastIndexOf("/")))
					{
					alert("The Entered Date is Not in Proper Format");
					return false;
					}
                while (intsep!=-1)
                {
                        intsep=strdate.indexOf("/",intstart);
                        if (intsep==-1)
                                intdate[intcount]=strdate.substr(intstart)
                        else
                                intdate[intcount]=strdate.substr(intstart,intsep-intstart)
                        intstart=intsep+1
                        intcount=intcount+1
                }
                if ((intdate[0]=="")||(intdate[1]=="")||(intdate[2]==""))
                {
					alert("The entered date is Not in Proper Format");
					return false;
                }
                var str = intdate[0]+"/"+intdate[1]+"/"+intdate[2];
				var d=new Date(str)
                if ((ValidateDigits(intdate[0],Cont_Name,"Y")==false)||(ValidateDigits(intdate[1],Cont_Name,"Y")==false)||(ValidateDigits(intdate[2],Cont_Name,"Y")==false))
                {
					//alert("Only Numeric is allowed in Date");
					return false;
                }
                else if ((intdate[1]!= d.getDate()) || (intdate[0]!= d.getMonth()+1) || (intdate[2]!=d.getFullYear()))
                {
                        alert("For " +  Cont_Name + " the value '" + Cont_Value + "' is not a valid Date. Please enter a valid date in  mm/dd/yyyy (eg. 11/13/2002) format.")
                        return false;
                }
	       else if(intdate[0].length>2)
               {
                     alert("For " +  Cont_Name + " the value '" + Cont_Value + "' is not a valid Month. Please enter a valid date in  mm/dd/yyyy (eg. 13/11/2002) format.")
                     return false;
               }
	       else if(intdate[1].length>2)
               {
                     alert("For " +  Cont_Name + " the value '" + Cont_Value + "' is not a valid Day. Please enter a valid date in  mm/dd/yyyy (eg. 13/11/2002) format.")
                     return false;
               }	
              	
              else if(intdate[2].length>4 || intdate[2].length <4)
               {
                     alert("For " +  Cont_Name + " the value '" + Cont_Value + "' is not a valid Year. Please enter a valid date in  mm/dd/yyyy (eg. 13/11/2002) format.")
                     return false;
               }
	
             else if((intdate[2]<1900))
                {
                alert("Only year greater than 1900 are allowed in "+ Cont_Name + " Please re-enter a valid year greater than 1900.");
                        return false;
                 }
			else if(d>date)
			{
				var month = date.getMonth()+1;
				alert(Cont_Name+ " cannot exceed current date. Please re-enter date less than or equal to " +month+"/"+date.getDate()+"/"+date.getFullYear()); 
				return false;
			}
		}
			else
					return true;
}  


// function to validate date in "mm/dd/yyyy" format and allows year from 1900 to future year also
 
function ValidateAnyDate(input,control,compulsory)
{
        var Cont_Value = input;
        var Cont_Name =control;
        var Cont_Validate=compulsory;
        var date = new Date();
        if ((Cont_Validate=="Y") &&(Cont_Value.length==0))
        {
                alert (Cont_Name + " is left blank. Please fill-in this field.")
                return false
        }
        else if (Cont_Value!="")
        {
	
                var strdate=Cont_Value
                var intstart=0
                var intsep=0
                var intcount=0
                var intdate=new Array(2)
 
                while (intsep!=-1)
                {
                        intsep=strdate.indexOf("/",intstart);
                        if (intsep==-1)
                                intdate[intcount]=strdate.substr(intstart)
                        else
                                intdate[intcount]=strdate.substr(intstart,intsep-intstart)
                        intstart=intsep+1
                        intcount=intcount+1
                }
                var str = intdate[0]+"/"+intdate[1]+"/"+intdate[2];
	        var d=new Date(str)

                if ((intdate[1]!= d.getDate()) || (intdate[0]!= d.getMonth()+1) || (intdate[2]!=d.getFullYear()))
                {
                         alert("For " +  Cont_Name + " the value " + Cont_Value + " is not a valid date. Please enter a valid date in  mm/dd/yyyy (eg. 11/13/2002) format.")
                        return false
                }
	       if(intdate[0].length>2)
               {
                     alert("For " +  Cont_Name + " the value " + Cont_Value + " is not a valid date. Please enter a valid date in  mm/dd/yyyy (eg. 11/13/2002) format.")
                     return false
               }
	       if(intdate[1].length>2)
               {
                      alert("For " +  Cont_Name + " the value " + Cont_Value + " is not a valid date. Please enter a valid date in  mm/dd/yyyy (eg. 11/13/2002) format.")
                     return false
               }	
              	
              if(intdate[2].length>4 || intdate[2].length <4)
               {
                	alert("For " +  Cont_Name + " the value " + Cont_Value + " is not a valid date. Please enter a valid date in  mm/dd/yyyy (eg. 11/13/2002) format.")
                     return false
               }
	
             if((intdate[2]<1900))
                {
                alert("Only year greater than 1900 are allowed in "+ Cont_Name + " Please re-enter a valid year greater than 1900.");
                        return false;
	         
        	}
        
			
        }
        else
                return true
} 
                                              


// function to compare date, validate format, check for Not Null or Null for mm/dd/yyyy format
//latest code 


function ValidateLeadDate(Linput,input,control,compulsory)
{
	var dtmBidDate=Linput;
	var dtmLeadDate=input;
	Cont_Value=input;
	Cont_Name=control;
	Cont_Validate=compulsory;
	
	if ((Cont_Validate=="Y") &&(Cont_Value.length==0))
	{
		alert (Cont_Name + " cannot be blank")
		return false
	}
	else if((chkDate(dtmLeadDate,Cont_Name,Cont_Validate)== false))
	{
		return false
	}
	else if (Cont_Value!="")
	{
		var Byear
		var Lyear
		var Lmon
		var Bmon
		var Lday
		var Bday
	
		var MonPosLDate = dtmLeadDate.indexOf("/",-1)
		var DayPosLDate= dtmLeadDate.lastIndexOf("/")
	
		var MonPosBDate = dtmBidDate.indexOf("/",-1)
		var DayPosBDate= dtmBidDate.lastIndexOf("/")
			
		Lyear=dtmLeadDate.substr(eval(DayPosLDate+1),4)
		Byear=dtmBidDate.substr(eval(DayPosBDate+1),4)
	
		Lmon=dtmLeadDate.substr(0,MonPosLDate)
		Bmon=dtmBidDate.substr(0,MonPosBDate)

		Lday=dtmLeadDate.substr(eval(MonPosLDate+1),eval(DayPosLDate-MonPosLDate-1))
		Bday=dtmBidDate.substr(eval(MonPosBDate+1),eval(DayPosBDate-MonPosBDate-1))
	
		if (eval(Lyear)>eval(Byear))
		{
			return true
		}
		else if ((eval(Lyear)==eval(Byear)) && (eval(Lmon)>eval(Bmon)))
		{
			return true
		}
		else if ((eval(Lyear)==eval(Byear)) && (eval(Lmon)== eval(Bmon)) && (eval(Lday)>=eval(Bday)))
		{
			return true
		}
		else
		{
			alert(Cont_Name + " should be later to From date")
			return false
		}

	}
	else
		return true
}

///to check complaint date

function ValidateLeadDateComp(Linput,input,control,compulsory)
{
	var dtmBidDate=Linput;
	var dtmLeadDate=input;
	Cont_Value=input;
	Cont_Name=control;
	Cont_Validate=compulsory;
	
	if ((Cont_Validate=="Y") &&(Cont_Value.length==0))
	{
		alert (Cont_Name + " cannot be blank")
		return false
	}
	else if((chkDate(dtmLeadDate,Cont_Name,Cont_Validate)== false))
	{
		return false
	}
	else if (Cont_Value!="")
	{
		var Byear
		var Lyear
		var Lmon
		var Bmon
		var Lday
		var Bday
	
		var MonPosLDate = dtmLeadDate.indexOf("/",-1)
		var DayPosLDate= dtmLeadDate.lastIndexOf("/")
	
		var MonPosBDate = dtmBidDate.indexOf("/",-1)
		var DayPosBDate= dtmBidDate.lastIndexOf("/")
			
		Lyear=dtmLeadDate.substr(eval(DayPosLDate+1),4)
		Byear=dtmBidDate.substr(eval(DayPosBDate+1),4)
	
		Lmon=dtmLeadDate.substr(0,MonPosLDate)
		Bmon=dtmBidDate.substr(0,MonPosBDate)

		Lday=dtmLeadDate.substr(eval(MonPosLDate+1),eval(DayPosLDate-MonPosLDate-1))
		Bday=dtmBidDate.substr(eval(MonPosBDate+1),eval(DayPosBDate-MonPosBDate-1))
	
		if (eval(Lyear)>eval(Byear))
		{
			return true
		}
		else if ((eval(Lyear)==eval(Byear)) && (eval(Lmon)>eval(Bmon)))
		{
			return true
		}
		else if ((eval(Lyear)==eval(Byear)) && (eval(Lmon)== eval(Bmon)) && (eval(Lday)>=eval(Bday)))
		{
			return true
		}
		else
		{
			alert(Cont_Name + " should be later to Complaint date")
			return false
		}

	}
	else
		return true
}

//to check whether an item is selected in combo 

function ValidateCombo(input,control,compulsory)
{
	var Cont_Value = input;
	var Cont_Name = control;
	var Cont_Validate=compulsory;
	
	//if (Cont_Value.selectedIndex==0||Cont_Value=="")
	
	if(((Cont_Value=="Please Select")||(Cont_Value=="")||(Cont_Value=="All"))&&(Cont_Validate=="Y"))
	{
		alert("Please select one of the options in " + Cont_Name);
		return false;		
	}
	else
		return true;
}

function ValidateCurrency(input,control,compulsory)
{
	var Cont_Value = input;
    var Cont_Name =control;
    var Cont_Validate=compulsory;
    
    if ((Cont_Validate=="Y") &&(Cont_Value.length==0))
	{
		alert (Cont_Name + " is left blank. Please fill-in this field.")
		return false
	}
	else if ((Cont_Validate=="Y") &&(Cont_Value.charAt(0)==" "))
	{
	alert("Only numbers greater than zero are allowed in the " + Cont_Name + " Please re-enter valid numbers in this field.")
	//alert(Cont_Name + " can allow only values greater than Zero. Please re-enter the data.")
		return false;
	}
	else if ((Cont_Value.charAt(0)==" "))
	{
	alert("Only numbers greater than zero are allowed in the " + Cont_Name + " Please re-enter valid numbers in this field.")
	//alert(Cont_Name + " can allow only values greater than Zero. Please re-enter the data.")
		return false
	}
	else if ((Cont_Value.charAt(0)=="0"))
	{
	alert("Only numbers greater than zero are allowed in the " + Cont_Name + " Please re-enter valid numbers in this field.")
	//alert(Cont_Name + " can allow only values greater than Zero. Please re-enter the data.")
		return false
	}
	
	else if(isNaN(Cont_Value))
	{
	alert("Only numbers greater than zero are allowed in the " + Cont_Name + " Please re-enter valid numbers in this field.")
//alert(Cont_Name + " can allow only values greater than Zero. Please re-enter the data.")
		return false;
	}
	else if((Cont_Value.charAt(0)=="+") || (Cont_Value.charAt(0)=="-"))
	{
	alert("Only numbers greater than zero are allowed in the " + Cont_Name + " Please re-enter valid numbers in this field.")
	//alert(Cont_Name + " can allow only values greater than Zero. Please re-enter the data.")
		return false;
	}
	else if (Cont_Value<0)
	{
	alert("Only numbers greater than zero are allowed in the " + Cont_Name + " Please re-enter valid numbers in this field.")		
	//alert(Cont_Name + " can allow only values greater than Zero. Please re-enter the data.")
		return false;
	}
	else if(validateTwoDigits(input, control, compulsory)==false)
	{
		alert(Cont_Name + " allows only 2 digits after decimal (eg. 45.45) Please re-enter correct data");
		return false;
	}
	else 
		return true;
	
}

//only Alphabets 

function OnlyAlphabets(input,control,compulsory)
{
	var Cont_Value = input;
	var Cont_Name =control;
	var Cont_Validate=compulsory;
	
	if ((Cont_Validate=="Y") && (Cont_Value.length==0))
	{
		 alert (Cont_Name + " is left blank. Please fill-in this field.")
			return false
	}
	else if ((chkBlankSpaces(Cont_Value,Cont_Name,Cont_Validate)==false))
	{
		alert (Cont_Name + " does not allow blank spaces. Please remove blank spaces and re-enter data.")
		return false;
	}
	
	else if (Cont_Value!="")
	{
		for(i=0;i<Cont_Value.length;i++)
		{
			var str=Cont_Value.charAt(i)
			if (!((str >= "A" && str <= "Z" ) || (str >= "a" && str <= "z")))
			{	
				alert ("Only alphabets are allowed in " + Cont_Name + " (eg. quality).  Please re-enter correct data.")
				return false
			}
		}
	}
	else
		return true
}



//only Alphabets 

function OnlyAlphabetSpace(input,control,compulsory)
{
	var Cont_Value = input;
	var Cont_Name =control;
	var Cont_Validate=compulsory;
	
	if ((Cont_Validate=="Y") && (Cont_Value.length==0))
	{
		 alert (Cont_Name + " is left blank. Please fill-in this field.")
			return false
	}
	else if((Cont_Validate=="Y") && (Cont_Value.charAt(0)==" "))
	{
		alert (Cont_Name + " does not allow a data with first character as a blank character. Please re-enter the data.")
		return false
	}
	else if ((Cont_Value.charAt(0)==" "))
	{
		alert (Cont_Name + " does not allow a data with first character as a blank character. Please re-enter the data.")
		return false
	}
	else if (Cont_Value!="")
	{
		for(i=0;i<Cont_Value.length;i++)
		{
			var str=Cont_Value.charAt(i)
			if (!((str >= "A" && str <= "Z" ) || (str >= "a" && str <= "z") || str==" "||(str=="&")))
			{	
				alert ("Only alphabets, space are allowed in " + Cont_Name + " (eg. quality).  Please re-enter correct data.")
				return false
			}
		}
	}
	else
		return true
}




	
// function to check blank spaces

function chkBlankSpaces(input,control,compulsory)
{	
	var Cont_Value=input;
	var Cont_Name=control;
	var Cont_Validate=compulsory;
	var intcheckblank=0;
		
	for(i=0;i<Cont_Value.length;i++)
	{
		var str=Cont_Value.charAt(i)
		if (str == " ")
		{	
			return false;
		}
	}
	return true;
		
	
}



function OnlyAlphabetSpacedot(input,control,compulsory)
{
	var Cont_Value = input;
	var Cont_Name =control;
	var Cont_Validate=compulsory;
	
	if ((Cont_Validate=="Y") && (Cont_Value.length==0))
	{
		 alert (Cont_Name + " is left blank. Please fill-in this field.")
			return false
	}
	else if((Cont_Validate=="Y") && (Cont_Value.charAt(0)==" "))
	{
		
		alert (Cont_Name + " does not allow a data with first character as a blank character. Please re-enter the data.")
		return false
	}
	else if ((Cont_Value.charAt(0)==" "))
	{
		alert (Cont_Name + " does not allow a data with first character as a blank character. Please re-enter the data.")
		return false
	}
	else if (Cont_Value!="")
	{
		for(i=0;i<Cont_Value.length;i++)
		{
			var str=Cont_Value.charAt(i)
			if (!((str >= "A" && str <= "Z" )||(str = "." )||(str = "-" )||(str = "()" ) || (str >= "a" && str <= "z") || (str==" ")||(str=="&")))
			{	
				alert ("Only alphabets, space are allowed in " + Cont_Name + " (eg. quality).  Please re-enter correct data.")
				return false
			}
		}
	}
	else
		return true
}


// Function to check 
function checkzero(input,control,compulsory)
{
	var Cont_Value = input;
	var Cont_Name =control;
	var Cont_Validate=compulsory;

	if ((Cont_Validate=="Y") &&(Cont_Value.length==0))
	{
		alert (Cont_Name + " is left blank. Please fill-in this field.")
		return false
	}

	else if((Cont_Value.charAt(0)=="+") || (Cont_Value.charAt(0)=="-"))
	{
		alert("Arithmetic characters are not allowed in " + Cont_Name + ". Please remove the arithmetic character and re-enter the data.")
		return false;
	} 
	 else if (Cont_Value!="")
	{
		
		if(  parseInt(Cont_Value) <=0 ) 
		{
		   	alert (" Only value greater than or equal to zero is allowed in " + Cont_Name + ". Please re-enter the data.")
			return false
		}	

		for(i=0;i<Cont_Value.length;i++)
			{
				var ch  = Cont_Value.charAt(i);
				if(ch=='.')
				  {
					alert ("Only integer values are allowed in " + Cont_Name + ". Please re-enter the data.")
					return false;
				 }
                        }
	}
	else
		return true;
}

//Validation only for numbers
function checkInteger(input,control,compulsory)
{
	var Cont_Value = input;
	var Cont_Name =control;
	var Cont_Validate=compulsory;
	var dotcount=0;
	//alert(isNaN(Cont_Value));
	

	if ((Cont_Validate=="Y") &&(Cont_Value.length==0))
	{
		alert (Cont_Name + " is left blank. Please fill-in this field.")
		return false
	}

	 else if((Cont_Value.charAt(0)=="+") || (Cont_Value.charAt(0)=="-"))
	{
		alert("Arithmetic characters are not allowed in " + Cont_Name + ". Please remove the arithmetic character and re-enter the data.")
		return false;
	}
	else if((Cont_Value.charAt(0)==".") && (Cont_Value.length==1) )
	{
		alert("First characters as '.' not allowed in " + Cont_Name + ". Please re-enter the data.")
		return false;
	}
	else if (Cont_Value!="")
	{
		
		if(  parseInt(Cont_Value) < 0 ) 
		{
		   	alert (" Only value greater than or equal to zero is allowed in " + Cont_Name + ". Please re-enter the data.")
			return false
		}
		else if(validateTwoDigits(Cont_Value,Cont_Name,Cont_Validate) == false)	{
			alert(Cont_Name + " allows only 2 digits after decimal (eg. 45.45) Please re-enter correct data");
			return false;
		}

		for(i=0;i<Cont_Value.length;i++)
		{
			var str=Cont_Value.charAt(i);
			
			if(str=='.'){
					dotcount = dotcount + 1;
			}
			if(dotcount>1){
			
					alert ("Only integer values are allowed in " + Cont_Name + ". Please re-enter the data.")
					return false
			}	
			if (!( (str >= 0 && str <=9)|| (str=='.')))
			{
					
					alert ("Only integer values are allowed in " + Cont_Name + ". Please re-enter the data.")
					return false
					
			}
			else
			{
				if((i == Cont_Value.length) && (str=='.') ){
				alert ("Only integer values are allowed in " + Cont_Name + ". Please re-enter the data.")
				return false
				}
			
			}
			
		}
	}
	else
	{
	
	return true;
	}	
}

//checking for Exchange rate
function checkExchangerate(input,control,compulsory,noofdigits)
{
	
	var Cont_Name =control;
	var Cont_Validate=compulsory;
	var Cont_Value = input;
	var Cont_NoOfDigits = noofdigits;
	
	if ((Cont_Validate=="Y") &&(Cont_Value.length==0))
	{
		alert (Cont_Name + " is left blank. Please fill-in this field.")
		return false
	}
	
	else if((Cont_Value.charAt(0)=="+") || (Cont_Value.charAt(0)=="-"))
	{
		alert("Only numbers greater than zero are allowed in the " + Cont_Name + " Please re-enter valid numbers in this field.")
		//alert(Cont_Name + " can allow only values greater than Zero. Please re-enter the data.")
		return false;
	}
	else if (Cont_Value!="")
		{
			if(isNaN(Cont_Value) || (Cont_Value.charAt(0)==" "))
			{
				alert("Only numbers greater than zero are allowed in the " + Cont_Name + " Please re-enter valid numbers in this field.")
				//alert(Cont_Name + " can allow only values greater than Zero. Please re-enter the data.")
				return false
			}	
			for(i=0;i<Cont_Value.length;i++)
			{
				var ch  = Cont_Value.charAt(i);
				if(ch=='.')
				 	 {
						var substr=Cont_Value.substring(i+1,Cont_Value.length);
					
						if(substr.length > Cont_NoOfDigits)
							{
								alert(Cont_Name + " Can allow Only " + Cont_NoOfDigits + " digits after decimal. Please re-enter data.")
					
								return false;
							}
				 		}
              }
			if(Cont_Value<=0)
			{
				alert("Only numbers greater than zero are allowed in the " + Cont_Name + " Please re-enter valid numbers in this field.")
				//alert(Cont_Name + " can allow only values greater than Zero. Please re-enter the data.")
				return false
			}	
						
		}
		else
		return true
}

//checking for amount
function checkFloat(input,control,compulsory)
{
	
	var Cont_Name =control;
	var Cont_Validate=compulsory;
	var Cont_Value = input;
	
	if ((Cont_Validate=="Y") &&(Cont_Value.length==0))
	{
		alert (Cont_Name + " is left blank. Please fill-in this field.")
		return false
	}
	
	else if((Cont_Value.charAt(0)=="+") || (Cont_Value.charAt(0)=="-"))
	{
		alert("Only numbers greater than zero are allowed in the " + Cont_Name + ". Please re-enter valid numbers in this field.")
		//alert(Cont_Name + " can allow only values greater than Zero. Please re-enter the data.")
		return false;
	}
	else if (Cont_Value!="")
		{
			if(isNaN(Cont_Value) || (Cont_Value.charAt(0)==" "))
			{
				alert("Only numbers greater than zero are allowed in the " + Cont_Name + ". Please re-enter valid numbers in this field.")
				//alert(Cont_Name + " can allow only values greater than Zero. Please re-enter the data.")
				return false
			}	
			for(i=0;i<Cont_Value.length;i++)
			{
				var ch  = Cont_Value.charAt(i);
				if(ch=='.')
				 	 {
						var substr=Cont_Value.substring(i+1,Cont_Value.length);
					
						if(substr.length > 2)
							{
								alert(Cont_Name + " Can allow Only Two digits after decimal. Please re-enter data.")
					
								return false;
							}
				 		}
              }
			if(Cont_Value<=0)
			{
				alert("Only numbers greater than zero are allowed in the " + Cont_Name + ". Please re-enter valid numbers in this field.")
				return false
			}	
						
		}
		else
		return true
}

// function to check only alphabets and numbers

function AlphaNum(input,control,compulsory)
{
	var Cont_Value = input;
	var Cont_Name =control;
	var Cont_Validate=compulsory;
	
	if ((Cont_Validate=="Y") &&(Cont_Value.length==0))
	{
		alert (Cont_Name + " is left blank. Please fill-in this field.")
		return false
	}	
	
	else if ((Cont_Validate=="Y") && (Cont_Value.length==0))
	{
		alert (Cont_Name + " is left blank. Please fill-in this field.")
		return false
	}
	else if ((chkBlankSpaces(Cont_Value,Cont_Name,Cont_Validate)==false))
	{
			alert (Cont_Name + " does not allow spaces. Please re-enter the data.")
			return false
	}	
	else if (Cont_Value!="")
	{
		for(i=0;i<Cont_Value.length;i++)
		{
			var str=Cont_Value.charAt(i)
			if (!((str >= "A" && str <= "Z" ) || (str >= "a" && str <= "z") || (str >= 0 && str <=9)))
			{	
				alert (Cont_Name + " allows only Alphabets and Integers (eg. quantity1). Please re-enter the data." )
				return false
			}
		}
	}

	return true;
}


function AlphaNumWithSpace(input,control,compulsory)
{
	var Cont_Value = input;
	var Cont_Name =control;
	var Cont_Validate=compulsory;
	
	if ((Cont_Validate=="Y") &&(Cont_Value.length==0))
	{
		alert (Cont_Name + " is left blank. Please fill-in this field.")
		return false
	}	
	else if ((Cont_Validate=="Y") &&(Cont_Value.charAt(0)==" "))
	{
		alert (Cont_Name + " does not allow a data with first character as a blank character. Please re-enter the data.")
		return false
	}
	else if ((Cont_Value.charAt(0)==" "))
	{
		alert (Cont_Name + " does not allow a data with first character as a blank character. Please re-enter the data.")
		return false
	}
	else if (Cont_Value!="")
	{
		for(i=0;i<Cont_Value.length;i++)
		{
			var str=Cont_Value.charAt(i)
			if (!((str >= "A" && str <= "Z" ) || (str >= "a" && str <= "z") || (str <= " ")  || (str >= 0 && str <=9)))
			{	
				alert (Cont_Name + " allows only Alphabets, Integers and space (eg. quantity1). Please re-enter data." )
				return false
			}
		}
	}
	else
		return true
}

function AlphaNumWithSpaceforDistricts(input,control,compulsory)
{
	var Cont_Value = input;
	var Cont_Name =control;
	var Cont_Validate=compulsory;
	
	if ((Cont_Validate=="Y") &&(Cont_Value.length==0))
	{
		alert (Cont_Name + " is left blank. Please fill-in this field.")
		return false
	}	
	else if ((Cont_Validate=="Y") &&(Cont_Value.charAt(0)==" "))
	{
		alert (Cont_Name + " does not allow a data with first character as a blank character. Please re-enter the data.")
		return false
	}
	else if ((Cont_Value.charAt(0)==" "))
	{
		alert (Cont_Name + " does not allow a data with first character as a blank character. Please re-enter the data.")
		return false
	}
	else if (Cont_Value!="")
	{
		for(i=0;i<Cont_Value.length;i++)
		{
			var str=Cont_Value.charAt(i)
			if (!((str >= "A" && str <= "Z" ) || (str >= "a" && str <= "z") || (str <= " ")  || (str >= 0 && str <=9) || (str == "-"  ) ||(str == ".") || (str == "'")   ))
			{	
				alert (Cont_Name + " allows only Alphabets, Integers, Hyphen , space and specialCahrectars (. ') (eg. quantity1-'.). Please re-enter data." )
				return false
			}
		}
	}
	else
		return true
}

// checking for only charcters 
function ValidAlpha(input,control,compulsory)
{
	var Cont_Value = input;
	var Cont_Name =control;
	var Cont_Validate=compulsory;
	//var flag=false;
	var spcount=0;
	
	for(i=0;i<Cont_Value.length;i++)
		{
			var str=Cont_Value.charAt(i)
			if (str==" ") spcount++;
			if (!((str >= "A" && str <= "Z" ) || (str >= "a" && str <= "z") || (str == " ") || (str == ".")))
			{	
			  alert (Cont_Name + " allows only alphabets,space and . (eg. Stage1). Please re-enter data")
			    //flag = false;                           
			}

		}
	if ((spcount==i) && (i != 0))
		//flag=false;

		return false
}

//function to check numbers


function ValidateDigits(input, control, compulsory,len)
{
	var Cont_Value = input;
	var Cont_Name =control;
	var Cont_Validate=compulsory;
	var re=/[0-9]/;
		
	if ((Cont_Value=="") && (Cont_Validate=="Y"))
	{
		alert (Cont_Name + " is left blank. Please fill-in this field.")
		return false;
	}
	else if ((Cont_Validate=="Y") &&(Cont_Value.charAt(0)==" "))
	{
		alert (Cont_Name + " does not allow a data with first character as a blank character. Please re-enter the data.")
		return false
	}
	else if ((Cont_Value.charAt(0)==" "))
	{
		alert (Cont_Name + " does not allow a data with first character as a blank character. Please re-enter the data.")
		return false
	}
//	else if ((Cont_Value.charAt(0)==0) && (Cont_Value!=""))
	//{
		//alert (Cont_Name + " does not allow a data with first character as a '0' character. Please re-enter the data.");
		//return false;
	//}
	else if((Cont_Value.charAt(0)=="+") || (Cont_Value.charAt(0)=="-"))
	{
		alert("Arithmetic characters are not allowed in " + Cont_Name + ". Please remove the arithmetic character and re-enter the data.")
		return false;
	}
	else if(!re.test(Cont_Value)&&(!Cont_Value=="")&&(Cont_Value >= 0 && Cont_Value <=9))
	{
		alert ("Please enter a valid number in "+ Cont_Name +  " NOTE: First character cannot be a zero and "  + Cont_Name + " allows only numbers greater than zero (eg. 12345). Please re-enter the data.")
		return false;
	}
	else if (!(Cont_Value==""))
	{
		for(i=0;i<Cont_Value.length;i++)
		{
			var str=Cont_Value.charAt(i);
			if ((!(str >= 0 && str <=9))||(str==' '))
			{	
				alert (" Only Numbers No Alphabets and Special characters are allowed in  " + Cont_Name + ".");
				return false;
			}
		}
	}
	else if ((!(len==0))&&!(Cont_Value==""))
	{
		if (Cont_Value.length<len)
		{
			alert(" Invalid " + Cont_Name + ". Minimun " + len + " Digits Required.");
			return false;
		}
	}
	else
	{
		return true;
	}
}




//function alphaNumaric with some special characters
function alphanumspecial(input,control,compulsory)
{
	var Cont_Value = input;
	var Cont_Name =control;
	var Cont_Validate=compulsory;

	
	if ((Cont_Value=="") && (Cont_Validate=="Y"))
	{
		alert (Cont_Name + " is left blank. Please fill-in this field.");
		return false
	}
	
	else if (Cont_Value.charAt(0)==" ")
	{
		alert (Cont_Name + " does not allow a data with first character as a blank character. Please re-enter the data.")
		return false;
	}
	else if((Cont_Value.charAt(0)=="."))
	{
		alert("First character of " + Cont_Name + " cannot be a dot. Please re-enter the data.");
		return false;
	}
	else if (Cont_Value!="")
	{
		for(i=0;i<Cont_Value.length;i++)
		{
			var str=Cont_Value.charAt(i)
			if (!((str >= "A" && str <= "Z" ) || (str >= "a" && str <= "z") ||(str == " ") || (str >= 0 && str <=9)|| (str=='.') || (str==',')||(str=="_")||(str=="@") || (str=='#')|| (str=='/') || (str=='\\') || (str=="-")|| (str=='+') || (str=='\\n')))
			{	
				alert ("Only alphabets, integers and special characters ( , . - @ # / \\ _  + )  are allowed in  " + Cont_Name + ". Please re-enter correct data.")
				return false
			}
		}
	}
		
	else 
		return true
}

function bloodpressure(input,control,compulsory)
{	
	var Cont_Value = input;
	var Cont_Name =control;
	var Cont_Validate=compulsory;

	if ((Cont_Value=="") && (Cont_Validate=="Y"))
	{
		alert (Cont_Name + " is left blank. Please fill-in this field.")
		return false;
	}
	else if ((Cont_Validate=="Y") &&(Cont_Value.charAt(0)==" "))
	{
		alert (Cont_Name + " does not allow a data with first character as a blank character. Please re-enter the data.")
		return false
	}
	else if ((Cont_Value.charAt(0)==" "))
	{
		alert (Cont_Name + " does not allow a data with first character as a blank character. Please re-enter the data.")
		return false
	}
	else if ((Cont_Value.charAt(0)==0) && (Cont_Value!=""))
	{
		alert (Cont_Name + " does not allow a data with first character as a '0' character. Please re-enter the data.");
		return false;
	}
	else if((Cont_Value.charAt(0)=="+") || (Cont_Value.charAt(0)=="-"))
	{
		alert("Arithmetic characters are not allowed in " + Cont_Name + ". Please remove the arithmetic character and re-enter the data.")
		return false;
	}
	else if(!isPin(Cont_Value))
	{
		alert ("Please enter a valid number in "+ Cont_Name +  " NOTE: First character cannot be a zero and "  + Cont_Name + " allows only numbers greater than zero (eg. 12345). Please re-enter the data.")
		return false;
	}
	else if (Cont_Value!="")
	{
		for(i=0;i<Cont_Value.length;i++)
		{
			var str=Cont_Value.charAt(i)
			if (!(str=='/') )
			{	
				alert ("Only alphabets, integers and special characters ( , . - @ # / \\ _  + )  are allowed in  " + Cont_Name + ". Please re-enter correct data.")
				return false
			}
		}
	}
	return true;
}	


//function alphaNumaric with some special characters
function searchalphanumspecial(input,control,compulsory)
{
	var Cont_Value = input;
	var Cont_Name =control;
	var Cont_Validate=compulsory;
	
	if ((Cont_Value=="") && (Cont_Validate=="Y"))
	{
		alert (Cont_Name + " is left blank. Please fill-in this field.");
		return false
	}
	
	
	else if (Cont_Value.charAt(0)=="")
	{
		alert (Cont_Name + " is left blank. Please fill-in this field.");
		return false;
	}
	
	else if (Cont_Value.charAt(0)==" ")
	{
		alert (Cont_Name + " does not allow a data with first character as a blank character. Please re-enter the data.")
		return false;
	}
	else if((Cont_Value.charAt(0)=="."))
	{
		alert("First character of " + Cont_Name + " cannot be a dot. Please re-enter the data.");
		return false;
	}
	else if (Cont_Value!="")
	{
		for(i=0;i<Cont_Value.length;i++)
		{
			var str=Cont_Value.charAt(i)
			if (!((str >= "A" && str <= "Z" ) || (str >= "a" && str <= "z") ||(str == " ") || (str >= 0 && str <=9)|| (str=='.')|| (str = "()" ) || (str==',')||(str=="_")||(str=="@") || (str=='#')|| (str=='/') || (str=='\\') || (str=="-")|| (str=='+')|| (str=='\\n')))
			{	
				alert ("Only alphabets, integers and special characters ( , . - @ # / \\ _  + )  are allowed in  " + Cont_Name + ". Please re-enter correct data.")
				return false
			}
		}
	}
	return true;
}

function chkPassword(input,cinput,control,compulsory)
{
	var Cont_Value = input;
	var Cont_Name =control;
	var Cont_Validate=compulsory;
	var cnfPassword=cinput;
	
	if ((Cont_Value=="") && (Cont_Validate=="Y"))
	{
		alert (Cont_Name + " is left blank. Please fill-in this field.")
		return false
	}
	else if ((cnfPassword=="") && (Cont_Validate=="Y"))
	{
		alert ("Confirm Password is left blank. Please fill-in this field.")
		return false
	}
	else if (Cont_Value != cnfPassword)
	{
		alert("Password and Confirm Password Must be Same")
		return false
	}
	else
		return true
}

function Password(input,control,compulsory)
{
	var Cont_Value = input;
	var Cont_Name =control;
	var Cont_Validate=compulsory;

	if ((Cont_Value=="") && (Cont_Validate=="Y"))
	{
		alert (Cont_Name + " is left blank. Please fill-in this field.")
		return false
	}
	else if (Cont_Value!="")
	{
		for(i=0;i<Cont_Value.length;i++)
		{
			var str=Cont_Value.charAt(i)
			if (!((str >= "A" && str <= "Z" ) || (str >= "a" && str <= "z") || (str >= 0 && str <=9)|| (str=='.')|| (str = "()" ) || (str==',')||(str=="_")||(str=="@") || (str=='#')|| (str=='/') || (str=='\\') || (str=="-")|| (str=='+')|| (str=='\\n')))
			{	
				alert ("Only alphabets, integers and special characters ( , . - @ # / \\ _  + )  are allowed in  " + Cont_Name + ". Please re-enter correct data.")
				return false
			}
		}
	}
	else
		return true

	
}


function logout()
{	
	document.parentWindow.parent.location="logout.asp"
		
}

function chkURL(url,textfield)
{  
  if((url!=""))
   {
   	url = url.toLowerCase();
	   while(url.charAt(0)== " ")    
	     {
		    url = url.substring(1,url.length);
	     }
		textfield.value	=	url;
		 if (url.substring(0,7)== "http://")
	 	    {
	 		 return true;
	 	   }
		 else
		 {
		    alert("URL Should Start with http://");
			return false;
	 	}
   }

}



function ValidateTwoDates(fromDate,toDate,control,compulsory)
{
	var dtFromDate=toDate;
	var dtToDate=fromDate;	
	Cont_Name=control;
	Cont_Validate=compulsory;
	
		var Byear
		var Lyear
		var Lmon
		var Bmon
		var Lday
		var Bday
	
		var MonPosLDate = dtToDate.indexOf("/",-1)
		var DayPosLDate= dtToDate.lastIndexOf("/")
	
		var MonPosBDate = dtFromDate.indexOf("/",-1)
		var DayPosBDate= dtFromDate.lastIndexOf("/")
			
		Lyear=dtToDate.substr(eval(DayPosLDate+1),4)
		Byear=dtFromDate.substr(eval(DayPosBDate+1),4)
	
		Lmon=dtToDate.substr(0,MonPosLDate)
		Bmon=dtFromDate.substr(0,MonPosBDate)

		Lday=dtToDate.substr(eval(MonPosLDate+1),eval(DayPosLDate-MonPosLDate-1))
		Bday=dtFromDate.substr(eval(MonPosBDate+1),eval(DayPosBDate-MonPosBDate-1))
		
		if (eval(Lyear)>eval(Byear))
		{
			return true
		}
		else if ((eval(Lyear)== eval(Byear)) && (eval(Lmon) > eval(Bmon)))
		{
			return true;
		}
		else if ((eval(Lyear)==eval(Byear)) && (eval(Lmon)== eval(Bmon)) && (eval(Lday)>=eval(Bday)))
		{
			return true;
		}
		else
		{
			alert("To Date entry should be later to the From date entry");
			return false;
		}		
}



//restricting field length
function FieldLength(input,control,compulsory,fieldlen)
{
	
	var Cont_Value = input;
	var Cont_Name =control;
	var Cont_Validate=compulsory;
	var Cont_Length=fieldlen;
	if ((Cont_Value=="") && (Cont_Validate=="Y"))
	{
		alert(Cont_Name + " is left blank. Please fill-in this field.")
		return false
	}
	else if ((Cont_Validate=="Y") && ((Cont_Value.charAt(0)==" ") || (Cont_Value.charCodeAt(0)=="13") || (Cont_Value.charCodeAt(0)=="32")))
	{
		alert (Cont_Name + " does not allow a data with first character as a blank or a new line character. Please re-enter the data.")
		return false
	}
	else if (Cont_Value.length > Cont_Length)
	{
		alert (Cont_Name + " Field Length Cannot be greater than " + Cont_Length + " Characters. Please enter data less than or equal to " + Cont_Length + "  characters.");

		return false
	}

	else
		//return alphanumspecial(input,control,compulsory);
		return true
}




function isNum(val){
 var re=/[^0-9]/;
 return !re.test(val);
}


//function to accept only numeric it will accept 0 as first digit also
function ValidateNumber(input, control, compulsory)
{
 var Cont_Value = input;
 var Cont_Name =control;
 var Cont_Validate=compulsory;
 
 if ((Cont_Value=="") && (Cont_Validate=="Y"))
 {
  alert (Cont_Name + " is left blank. Please fill-in this field.")
  return false;
 }
 else if ((Cont_Validate=="Y") &&(Cont_Value.charAt(0)==" "))
 {
  alert (Cont_Name + " does not allow a data with first character as a blank character. Please re-enter the data.")
  return false
 }
 else if ((Cont_Value.charAt(0)==" "))
 {
  alert (Cont_Name + " does not allow a data with first character as a blank character. Please re-enter the data.")
  return false
 }
 else if((Cont_Value.charAt(0)=="+") || (Cont_Value.charAt(0)=="-"))
 {
  alert("Arithmetic characters are not allowed in " + Cont_Name + ". Please remove the arithmetic character and re-enter the data.")
  return false;
 }
 else if(!isNum(Cont_Value))
 {
  alert ("Please enter a valid number in "+ Cont_Name +  " and "  + Cont_Name + " allows only numbers (eg. 12345). Please re-enter the data.")
  return false;
 } 
 else
  return true;
}


function FundName(input,control,compulsory)
{
	var Cont_Value = input;
	var Cont_Name =control;
	var Cont_Validate=compulsory;
	
	if ((Cont_Validate=="Y") &&(Cont_Value.length==0))
	{
		alert (Cont_Name + " is left blank. Please fill-in this field.")
		return false
	}	
	else if ((Cont_Validate=="Y") &&(Cont_Value.charAt(0)==" "))
	{
		alert (Cont_Name + " does not allow a data with first character as a blank character. Please re-enter the data.")
		return false
	}
	else if ((Cont_Value.charAt(0)==" "))
	{
		alert (Cont_Name + " does not allow a data with first character as a blank character. Please re-enter the data.")
		return false
	}
	else if (Cont_Value!="")
	{
		for(i=0;i<Cont_Value.length;i++)
		{
			var str=Cont_Value.charAt(i)
			if (!((str >= "A" && str <= "Z" ) || (str >= "a" && str <= "z") || (str <= " ") || (str <= "-") || (str >= 0 && str <=9)) || (str=="'") || (str=="@") || (str=="&") || (str=="*") || (str=="!") || (str=="%") || (str=="#") || (str=="$") || (str=='"') || (str=="(") || (str==")") || (str==",") || (str=="+"))
			{	
				alert (Cont_Name + " allows only Alphabets, Integers, space and (-) (eg. quantity-1). Please re-enter data." )
				return false
			}
		}
	}
	else
		return true
}

function chkDate(input,control,compulsory)
{
	var Cont_Value = input;
	var Cont_Name =control;
	var Cont_Validate=compulsory;

	if ((Cont_Validate=="Y") &&(Cont_Value.length==0))
	{
		alert (Cont_Name + " cannot be blank")
		return false
	}
	else if (Cont_Value!="")
	{	
		var strdate=Cont_Value
		var intstart=0
		var intsep=0
		var intcount=0
		var intdate=new Array(2)

		while (intsep!=-1)
		{
			intsep=strdate.indexOf("/",intstart);
			if (intsep==-1) 
				intdate[intcount]=strdate.substr(intstart)
			else	
				intdate[intcount]=strdate.substr(intstart,intsep-intstart)
			intstart=intsep+1
			intcount=intcount+1
		}

		var d=new Date(strdate)
		if ((intdate[0]!=d.getMonth()+1) || (intdate[1]!=d.getDate()) || (intdate[2]!=d.getFullYear()))
		{
			alert("Enter Date in 'mm/dd/yyyy' format")
			return false			
		}
		else if ((eval(intdate[2]) < 1900))
		{
			alert("Year entry should be later to 1900")
			return false
        }
        else if ((eval(intdate[2]) > 9999))
        {
           alert("Year entry should be below 9999")
			return false
        }
	}
	else
		return true
		
}


function ValidateFuture(fromDate,toDate,control,compulsory)
{

	var dtFromDate=toDate;
	var dtToDate=fromDate;	
	Cont_Name=control;
	Cont_Validate=compulsory;
	
	
		var Byear
		var Lyear
		var Lmon
		var Bmon
		var Lday
		var Bday
	
		var MonPosLDate = dtToDate.indexOf("/",-1)
		var DayPosLDate= dtToDate.lastIndexOf("/")
	
		var MonPosBDate = dtFromDate.indexOf("/",-1)
		var DayPosBDate= dtFromDate.lastIndexOf("/")
			
		Lyear=dtToDate.substr(eval(DayPosLDate+1),4)
		Byear=dtFromDate.substr(eval(DayPosBDate+1),4)
	
		Lmon=dtToDate.substr(0,MonPosLDate)
		Bmon=dtFromDate.substr(0,MonPosBDate)

		Lday=dtToDate.substr(eval(MonPosLDate+1),eval(DayPosLDate-MonPosLDate-1))
		Bday=dtFromDate.substr(eval(MonPosBDate+1),eval(DayPosBDate-MonPosBDate-1))
	
		if (eval(Lyear)>eval(Byear))
		{
			return true
		}
		else if ((eval(Lyear)== eval(Byear)) && (eval(Lmon) > eval(Bmon)))
		{
			return true
		}
		else if ((eval(Lyear)==eval(Byear)) && (eval(Lmon)== eval(Bmon)) && (eval(Lday)>=eval(Bday)))
		{
			return true
		}
		else
		{
			alert("DOJ cannot be Future date")
			return false
		}		    
}

function chkEMail(input,control,compulsory)
{
	var Cont_Value = input;
	var Cont_Name =control;
	var Cont_Validate=compulsory;
	
	if ((Cont_Validate=="Y") &&(Cont_Value.length==0))
	{
		alert (Cont_Name + " field left blank. Please fill in this field.")
		return false
	}
	else if(!(Cont_Value==""))
	{
		return ValidateMail(Cont_Value, Cont_Name)	
	}
	else if ((Cont_Value=="") && (Cont_Validate=="N"))
	{
		//alert(Cont_Name + " cannot be blank")
		return true
	}
	else if (ValidateMail(Cont_Value, Cont_Name)== false)
	{
		return false
	}			
	else 
		return true
}


function ValidateMail(x,y)
{
 var url=x;
 var re=/[A-Za-z._]/;
 var re0=/[A-Za-z]/;
 var re1=/[._]/;
	if (url != null && url != "") 
	{
	a = url.lastIndexOf("@");
	b = url.lastIndexOf(".");
	c = url.indexOf(":");
	d = url.indexOf("/");
	e = url.substring(0,a);
	f = e.indexOf("@");
	g = url.substring(a+1,url.length);
	h = g.indexOf("[");
	i = g.indexOf("]");
	j = g.indexOf("<");
	k = g.indexOf(">");
	l = url.substring(a+1,b);
	m = url.substring(b+1,url.length);
	n = url.substring(0,a);
	o = 0;
	p = url.indexOf(" ");
	q = url.substring(a-1,a);
	r = n.substring(0,n.lastIndexOf("."));
	s = url.charAt(0);
	t = url.charAt(a+1);
	if (!re0.test(s)==true) {o++};
	if (!re0.test(t)==true) {o++};
	if (r.indexOf(".")!= -1) {o++};
	if (!re.test(n)==true) {o++};
	if (re1.test(q)==true) {o++};
	if (a > b) {o++};
	if (c != -1) {o++};
	if (d != -1) {o++};
	if (f != -1) {o++};
	if (h != -1) {o++};
	if (i != -1) {o++};
	if (j != -1) {o++};
	if (k != -1) {o++};
	if (p != -1) {o++};
	if (l.length < 3) {o++};
	if (m.length < 2) {o++};
	if (m.length > 4) {o++};
	if (n.length < 1) {o++};
	if (!(o == 0) )
	{
		alert("Enter valid E-Mail Address");
		return false;
	}
	else if (url!="")
	{
		for(i=0;i<url.length;i++)
		{
			var str=url.charAt(i);
			//for two dots repetetion
			if (i!=url.length)
			{
				var str1=url.charAt(i+1);
				if ((re1.test(str)==true)&&(re1.test(str1)==true))
				{ return false; }
			}
			if (!((str >= "A" && str <= "Z" ) || (str >= "a" && str <= "z") || (str >= 0 && str <=9)|| (str=='.') ||(str=="_")||(str=="@") || (str=="-")))
			{	
				alert("Enter valid E-Mail Address");
				//alert ("Only alphabets, integers and special characters ( , . ' - @ # / \\& _  + %)  are allowed in  " + Cont_Name + ". Please re-enter correct data.")
				return false;
			}
		}
	}
	}
}




//This function is to validate indicator

function Onlyforindicatorvalidate(input,control,compulsory,i,controlName)
{
	var Cont_Value = input;
	var Cont_Name =control;
	var Cont_Validate=compulsory;
	var inputName = controlName;
	
	if ((Cont_Validate=="Y") && (Cont_Value.length==0))
	{
		 alert (inputName + " is left blank. Please fill-in this field.");
		 document.getElementById(Cont_Name).focus();	 		 
		 return false;
	}	
	else if (Cont_Value!="")
	{
		for(i=0;i<Cont_Value.length;i++)
		{
			var str=Cont_Value.charAt(i)
			if (!((str >= "A" && str <= "Z" ) || (str >= "a" && str <= "z") || str==" " || (str >= 0 && str <= 9)))
			{	
				alert ("Only alphanumeric, space are allowed in " + inputName + " (eg. quality 123).  Please re-enter correct data.");
				document.getElementById(Cont_Name).focus();	 		 
				return false;
			}
			else if (Cont_Value.charAt(0)==" ")
			{
						alert (inputName + " does not allow a data with first character as a blank character. Please re-enter the data.")
						document.getElementById(Cont_Name).focus();
						return false
			}
		}
	}

	return true;
}



function alphanumspecialforindicators(input,control,compulsory,k)
{
	var Cont_Value = input;
	var Cont_Name =control;
	var Cont_Validate=compulsory;
	
	if ((Cont_Value=="") && (Cont_Validate=="Y"))
	{
		alert (Cont_Name + " is left blank.Please fill-in this field at Row " + k + " .");
		return false
	}
	else if (Cont_Value.charAt(0)==" ")
	{
		alert (Cont_Name + " does not allow a data with first character as a blank character. Please re-enter the data at Row "+ k + " .");
		return false;
	}
	else if((Cont_Value.charAt(0)=="."))
	{
		alert("First character of " + Cont_Name + " cannot be a dot. Please re-enter the data at Row "+ k + " .");
		return false;
	}
	else if (Cont_Value!="")
	{
		for(i=0;i<Cont_Value.length;i++)
		{
			var str=Cont_Value.charAt(i)
			if (!((str >= "A" && str <= "Z" ) || (str >= "a" && str <= "z") ||(str == " ") || (str >= 0 && str <=9)|| (str=='.') || (str=="_")||(str=="@") || (str=='#')||(str=='$')|| (str=='/') ||(str=='%')|| (str==')') ||(str=='(')|| (str=="-")|| (str=='+')))
			{	
				alert ("Only alphabets, integers and special characters ( . - @ # ( ) / _ % $ +  )  are allowed in  " + Cont_Name + ". Please re-enter correct data at Row "+ k + " .");
				return false //(str=="'") || (str==',')||(str=='\\') || (str=='\\n')
			}
		}
	}
		
	else 
		return true
}





function alphanumspecialforDistricts(input,control,compulsory,k)
{
	var Cont_Value = input;
	var Cont_Name =control;
	var Cont_Validate=compulsory;
	
	if ((Cont_Value=="") && (Cont_Validate=="Y"))
	{
		alert (Cont_Name + " is left blank.Please fill-in this field at Row " + k + " .");
		return false
	}
	else if (Cont_Value.charAt(0)==" ")
	{
		alert (Cont_Name + " does not allow a data with first character as a blank character. Please re-enter the data at Row "+ k + " .");
		return false;
	}
	else if((Cont_Value.charAt(0)=="."))
	{
		alert("First character of " + Cont_Name + " cannot be a dot. Please re-enter the data at Row "+ k + " .");
		return false;
	}
	else if (Cont_Value!="")
	{
		for(i=0;i<Cont_Value.length;i++)
		{
			var str=Cont_Value.charAt(i)
			if (!((str >= "A" && str <= "Z" ) || (str >= "a" && str <= "z") ||(str == " ") || (str >= 0 && str <=9)|| (str=='.') ||  (str==',')||(str=="_")||(str=="@") || (str=='#')|| (str=='/') || (str=='\\') || (str=="-")|| (str=='+') || (str=='\\n')))
			{	
				alert ("Only alphabets, integers and special characters ( , .  - @ # / \\ _  + )  are allowed in  " + Cont_Name + ". Please re-enter correct data at Row "+ k + " .");
				return false
			}
		}
	}
		
	else 
		return true
}





function checkforzeroinstateId(input,control,compulsory)
{
	var Cont_Value = input;
	var Cont_Name =control;
	var Cont_Validate=compulsory;

	if ((Cont_Validate=="Y") &&(Cont_Value.length==0))
	{
		alert (Cont_Name + " is left blank. Please fill-in this field.")
		return false
	}

	else if((Cont_Value.charAt(0)=="+") || (Cont_Value.charAt(0)=="-"))
	{
		alert("Arithmetic characters are not allowed in " + Cont_Name + ". Please remove the arithmetic character and re-enter the data.")
		return false;
	} 
	 else if (Cont_Value!="")
	{
		
		if(Cont_Value=="0" || parseInt(Cont_Value) < 0  ) 
		{
		   	alert (" Only value greater than 0 is allowed in " + Cont_Name + ". Please re-enter the data.")
			return false
		}	
		
		for(i=0;i<Cont_Value.length;i++)
			{
				var ch  = Cont_Value.charAt(i);
				if(ch=='.')
				  {
					alert ("Only integer values are allowed in " + Cont_Name + ". Please re-enter the data.")
					return false;
				 }
             }
	}
	else
		return true;
}








