



//Author Puneet Raj

//Date   5 Sep 2005

//Purpose********************This is the the Common file for*************
//***************************Client side validations to be done **********

function FDigitsOnly(strfieldValue)
{	
	//alert(strfieldValue)
	var strDigits = "0123456789."
	var flag;
	
	for(i=0;i<strfieldValue.length;i++)
	{
	//alert(strfieldValue.substring(i,i+1))
	if (strfieldValue.substring(i,i+1)=="0"||strfieldValue.substring(i,i+1)=="1"||
			strfieldValue.substring(i,i+1)=="2"||strfieldValue.substring(i,i+1)=="3"||
			strfieldValue.substring(i,i+1)=="4"||strfieldValue.substring(i,i+1)=="5"||
			strfieldValue.substring(i,i+1)=="6"||strfieldValue.substring(i,i+1)=="7"||strfieldValue.substring(i,i+1)=="."||
			strfieldValue.substring(i,i+1)=="8"||strfieldValue.substring(i,i+1)=="9"){
			
			flag=true;
		}
			else{
			flag=false;
			return(false);
		}	
			//alert(flag)
	}
	if (flag==false){
	return(false)}else{
	return(true)};
}

function func_CheckValid_Data(ctrl_name ,ctrl_value)
{
var strToCheck;
var intlen;
intlen = ctrl_value.length;
strToCheck=ctrl_value;
if (intlen==0)
{
alert(ctrl_name + " Cannot be blank");
return false ;
}
var checkNum = "`~!@#$%^&*()-_+|\}]{[:;'<,>.?/ 0123456789";
			   

for (var i=0;i<intlen;i++)
{
	for(var j=0;j<checkNum.length;j++)
	{	
		if(strToCheck.charAt(i)==checkNum.charAt(j))
		{
		alert("Special and Numeric characters are not allowed in " + ctrl_name);
		return false;
		}
	}
}

if (intlen > 200)
{	
	
	alert("Maximum 200  characters is allowed in " + ctrl_name);
	return false;

}
return true;
}
//*************For Alphabets only********

// Added by Ahmed, to add alphabets and numeric values also
function func_CheckValid_Data1(ctrl_name ,ctrl_value)
{
var strToCheck;
var intlen;
intlen = ctrl_value.length;
strToCheck=ctrl_value;
if (intlen==0)
{
alert(ctrl_name + " Cannot be blank");
return false ;
}
var checkNum = "@#$%^&*()[]?<>!~`''";
//1234567890
for (var i=0;i<intlen;i++)
{
	for(var j=0;j<checkNum.length;j++)
	{	
		if(strToCheck.charAt(i)==checkNum.charAt(j))
		{
		alert("Special characters are not allowed in " + ctrl_name);
		return false;
		}
	}
}

if (intlen > 200)
{	
	
	alert("Maximum 200  characters is allowed in " + ctrl_name);
	return false;

}
return true;
}

//*********************Next Function for checking Digits Only***********
function DigitsOnly(strfieldValue)
{	
	//alert(strfieldValue)
	var strDigits = "0123456789";
	var flag;
	
	for(i=0;i<strfieldValue.length;i++)
	{
	//alert(strfieldValue.substring(i,i+1))
	if (strfieldValue.substring(i,i+1)=="0"||strfieldValue.substring(i,i+1)=="1"||strfieldValue.substring(i,i+1)=="2"||strfieldValue.substring(i,i+1)=="3"||strfieldValue.substring(i,i+1)=="4"||strfieldValue.substring(i,i+1)=="5"||strfieldValue.substring(i,i+1)=="6"||strfieldValue.substring(i,i+1)=="7"||strfieldValue.substring(i,i+1)=="8"||strfieldValue.substring(i,i+1)=="9"){
			
			flag=true;
		}
			else{
			flag=false;
			return(false);
		}	
			//alert(flag)
	}
	if (flag==false){
	return(false)}else{
	return(true)};
}
//*****************************For Checking the Numeric ***********
function func_NumericOnly(strData)
{			
var strNumeric=" "	;
var strAllowed = "0123456789";
for(i=0;i<strData.length;i++)
{
	if (strAllowed.indexOf(strData.charAt(i)!=-1))
		{
			strNumeric=strNumeric+strData.charAt(i);
		}
}
return strNumeric;
}

//Modified By alok Gupta For float Value acceptance
function func_floatOnly(strfieldValue)
{	
//alert(strfieldValue)
	var strDigits = "0123456789.";
	var flag;
	
	for(i=0;i<strfieldValue.length;i++)
	{
	//alert("hi");
	//alert(strfieldValue.substring(i,i+1))
	//alert("dsd");
	if (strfieldValue.substring(i,i+1)=="0"||strfieldValue.substring(i,i+1)=="1"||strfieldValue.substring(i,i+1)=="2"||strfieldValue.substring(i,i+1)=="3"||strfieldValue.substring(i,i+1)=="4"||strfieldValue.substring(i,i+1)=="5"||strfieldValue.substring(i,i+1)=="6"||strfieldValue.substring(i,i+1)=="7"||strfieldValue.substring(i,i+1)=="8"||strfieldValue.substring(i,i+1)=="9"||strfieldValue.substring(i,i+1)=="."){
			
			flag=true;
		}
			else{
			flag=false;
			return(false);
		}	
			//alert(flag)
	}
	if (flag==false){
	return(false)}else{
	return(true)};
}
//**********************Function for Selected Items ***********
function func_selectedItems(form)
{
	var temp=0;i=0;
	for (count=0;count<form.list1.length;count++)
	 {
		if (form.list1[count].selected)
		{
			i++;
		}
				
	 }	
	 alert(i);
}
//**********************Function to check for numeric data and special characters *****
function func_Check_Data(ctrl_Name,ctrl_Value)
{
var strToCheck,len;
strToCheck=ctrl_Value;
len=strToCheck.length;
if(len==0)
{
 alert(ctrl_Name + "can not be blank.");
 return false;
}
var checkNum=" 0123456789@#$%^&*(){}?<>!~`'"
for(i=0;i<len;i++)
{
 for(j=0;j<checkNum.length;j++)
	{
	  if(strToCheck.charAt(i)==checkNum .charAt(j))
	   {
	    alert("Number and special characters are not allowed in" + ctrl_Name);
	    return false;
	   }
	   
	}
}
return true
}
	    
//**********************Function for Date Validation **********	
function func_validateDate(strDD,strMM,strYYYY)
{
    var day;
	var mon;
	var year;
	var leapYear;
	if((strDD="DD")||(strMM="MM")||(strYYYY="YYYY"))
	 {
		alert("Please enter valid date!!!!");
		return false
	 }
	day=eval(strDD)
	mon=eval(strMM)
	year=eval(strYYYY)
	leapYear=(year%4==0)?1:0;
	if((leapYear) && (mon=2) && (day>29))
	 {
	  alert("Invalid Date!!!\n There can not be more than 29 days");
	  return false;
	 }
	 
	if(mon==2||mon==4||mon==6||mon==9||mon==11)
	 {
	  if(mon==2 & !leapYear && day>28)
	   {
	    alert("Invalid Date!!!\n February can't have more than 28 days ");
	    return false
	   }
	  if(day>30) 
	  {
	   alert("Invalid Date!!!" & "\n" &  "Should not have more than 30 days");
	   return false
	  }
	 }
	return true
	}

//********************** Function for Checking if field is empty **********		 
//********************** This function doesnt allow space between two words*****
function isBlank(field_Name,field_Value)
{
 var len;
 var i;
 var sTemp;
 sTemp=lrim(field_Value)
 len=sTemp.length
 if(len==0)
 {
  alert(field_Name + " cannot left blank");
  return false
 }
 for(i=0;i<len;++i)
  {
   if(sTemp.charAt(i)==" " )
   {
    alert("Please enter valid value in " + field_Name);
    return false
   }
  }
 return true;
}


//********************** Function for Checking if field is empty **********		 
//********************** This function allow space between two words*****
function isEmpty(field_Name,field_Value)
{
 var len;
 var i;
 var sTemp;
 sTemp=ltrim(field_Value)
 len=field_Value.length
 if(len==0)
 {
 alert(field_Name + " cannot left blank.");
 return false
 }
 return true;
}


//********************** Function for Checking special characters **********		 

//***************************change in fun func_specialChar var fieldValue to field_Value by alok  04102005**********************************
function func_specialChar(field_Name,field_Value)
{
 for(var i=0;i<=field_Value.length;i++)
	{
		if(field_Value.substring(i,i+1)=="~"||field_Value.substring(i,i+1)=="`"||field_Value.substring(i,i+1)=="!"||field_Value.substring(i,i+1)=="@"||field_Value.substring(i,i+1)=="#"||field_Value.substring(i,i+1)=="$"||field_Value.substring(i,i+1)=="%"||field_Value.substring(i,i+1)=="^"||field_Value.substring(i,i+1)=="&"||field_Value.substring(i,i+1)=="*"||field_Value.substring(i,i+1)=="("||field_Value.substring(i,i+1)==")"||field_Value.substring(i,i+1)=="{"||field_Value.substring(i,i+1)=="}"||field_Value.substring(i,i+1)=="["||field_Value.substring(i,i+1)=="]"||field_Value.substring(i,i+1)=="<"||field_Value.substring(i,i+1)==">"||field_Value.substring(i,i+1)=="?"||field_Value.substring(i,i+1)=="+"||field_Value.substring(i,i+1)=="*"||field_Value.substring(i,i+1)=="|"||field_Value.substring(i,i+1)==";")
			{
				alert("Special characters are not allowed in " + field_Name + " field");
				return false
			}
	}
return true
}

				
//********************** Function to remove left spaces **********		 				
function ltrim(strValue)
{
 var result="";
 var i=0;
 var string="";
 result=strValue;
 string=result.substring(0,1);
 while(string==" ")
  {
    if (result==" ") 
     {
       result="";
       string="";
     }
    else
     {
      result=result.substring(1,result.length-1);
      string=result.substring(0,1);
     }
    return(result);
}





//********************** Function to check some more special characters **********		 				
function func_Check_Special_Chars(field_Name,field_Value)
{
 var checkok="{}[]\/`~!@#$%^&*()_+|=-,.;':<>"
 var allvalid=true;
 strSpecial="";
 for(i=0;i<field_Value.length;i++)
	{
		ch=field_Value.charAt(i);
		if(ch!="") 
		 {
		  strSpecial=strSpecial+ch;
		 }
		for(j=0;j<ckeckok.length;j++)
		 if(ch==checkok.charat(j))
			break;
		 if(j==checkok.length)
		  {
		   allvalid=false;
		   break;
		  }
	}
	if (allvalid)
	{
	 alert("Please dont enter any special characters in " + field_Name);
	}
return(allvalid)
}

} 


/*-----------------------------E-mail Validation Function------------------------------------------*/
/*-----------------------------By: Ravi Kant Srivastava--------------------------------------------*/
/*-----------------------------12/29/2005----------------------------------------------------------*/	
	function check_mail(strMail,control)
	{

	var temp=strMail.split("@");
	 if(temp.length>2)
	 {
	// alert("Hi");
//Modified to get the focus on the box
	 control.select();
	  control.focus();
	  alert("You are using  '@' more than one time");
	  
	  return false;
	 }
	 var temp1=strMail;
	 for(i=0;i<temp1.length-1;i++)
	 {
	 	if(temp1.charAt(i)=="." && temp1.charAt(i+1)=="." )
			{
					control.select();
					control.focus();
					alert("You are using  '.' one after another");
					return false;
			}
		if(temp1.charAt(i)=="@" && temp1.charAt(i+1)=="@" )
			{
					
					control.select();
					control.focus();
					alert("You are using  '@' one after another");
					return false;
			}
			if(temp1.charAt(i)==" " )
			{
			
					control.select();
					control.focus();
					alert("Blank space is not allowed");
					return false;
			}
	 }
	 if(temp1.charAt(0)=="." || temp1.charAt(temp1.length)=="." )
			{
			
					control.select();
					control.focus();
					alert("no dots in start and end of E - mail  ID");
					return false;
			}
	if(temp1.charAt(0)=="#" || temp1.charAt(temp1.length)=="@" )
			{
			
					control.select();
					control.focus();
					alert("no @ in start and end of E - mail  ID");
					return false;
			}
	if(temp1.charAt(0)==" " || temp1.charAt(temp1.length)==" " )
			{
			
					control.select();
					control.focus();
					alert("no blank Space in start and end of E - mail  ID");
					return false;
			}
			return true;
	}

	
	/*
	function checkMail(strEmail)
	{
		
		
		
		
		var check1="@";
		var check2=".";
		var pass=0;
		var p1=0,p2=0,p3=0,p4=0,p5=0,p6=0;
		var len=strEmail.length;
		for(i=0;i<=len-1;i++)
			{
				if(strEmail.charAt(i)==check1)
					{
						p1=p1+1;
					}
				if(strEmail.charAt(i)==check1 && strEmail.charAt(i+1)==check2)
					{
						p3=p3+1;
					}
				if(strEmail.charAt(i)==check2 && strEmail.charAt(i+1)==check1)
					{
						p4=p4+1;
					}
				if(strEmail.charAt(i)==check2)
					{
						p2=p2+1;
					}
				
			}
		if(p3>0||p4>0)
			{
				return false;	
			}
		else
			{
				pass=p1+p2;
				if (pass<2 || pass==0)
					{
						return false;
					}
				else if(pass>=2)
					{
						return true;
					}
			}
			
	}
	
	/*var checkok="@.";
	var allvalid=true;
	var len=strEmail.length;
	var intposition;
	//alert(len)
	for(i=0;i<strEmail.length;i++)
	{
		if(strEmail.charAt(i)==".")
			{
				allvalid=true;
				break;
			}
		else
			{
				allvalid=false;
			}
	}
if(!allvalid)
	{
		alert("Please input valid Email address!!");
		return(0);
	}
 for(i=0;i<strEmail.length;i++)
	{
		if(strEmail.charAt(i)=="@")
			{
				allvalid=true;
				break;
			}
		else
			{
				allvalid=false;
			}
	}
for(i=0;i<len;i++)
	{
		if(strEmail.charAt(i)=="'")
			{
				allvalid=false;
				break;
			}
		else
			{
				allvalid=true;
			}
	}	
if(!allvalid)
	{
		alert("Please input valid Email address!!");
		return(0);
	}

if(strEmail.charAt(0)=="." ||strEmail.charAt(0)=="@" || strEmail.charAt(len-1)=="." || strEmail.charAt(len-1)=="@")
	{
		alert("Please input valid Email address!!");
		return(0);
	}
 var intPosition;
 intPosition=strEmail.indexOf("@",0)
 if(strEmail.charAt(intPosition-1)=="."||strEmail.charAt(intPosition+1)==".")
	{
		alert("Please input valid Email address!!");
		return(0);
	}
return(1);*/

//**************Function for Date Check
function oldCheckDate(strDate)
{
	//alert("kin check date")
	var dt = strDate;
	if (dt=="")
	{
		alert("Enter Date")
		return false;
	}
	if (dt.length!=10)
	{
	alert("Invalid Date the coreect format is mm/dd/yyyy");
	return false;
	}
	var m1=dt.charAt(0);
	var m2=dt.charAt(1);
	var d1=dt.charAt(3);
	var d2=dt.charAt(4);
	var y1=dt.charAt(6);
	var y2=dt.charAt(7);
	var y3=dt.charAt(8);
	var y4=dt.charAt(9);
	var day =d1+d2;
	var mon=m1+m2;
	var yr=y1+y2+y3+y4;
		
		if ((isNaN(day))||(isNaN(mon))||(isNaN(yr)))
		{
		alert("Invalid Date,Re Enter");
		return false;
		}
		
		if (mon>12)
		{
		alert("Invalid Date,Re-Enter");
		return false;
		}
		
		if ((mon==01)||(mon=03)||(mon==05)||(mon==07)||(mon==09)||(mon==11))
		{
			if ((day>31) || (day<1))
			{
				alert("Invalid Date ,Re-Enter");
				return false;
			}
		}
		if ((mon==04)||(mon=06)||(mon==08)||(mon==10)||(mon==12))
		{
			if ((day>30)||(day<1))
			{
			alert("Invalid Date ,Re-Enter")
			return false;
			}
		}
		
		if (mon==2)
		{
			if ((yr%4==0)&&(day>29))
			{
			alert("Invalid Date,Re-Enter")
			return false;
			}
		}
		
		return true;
}
//*********************For Checking Special Chars
function func_CheckSpecialChar(ctrl_name ,ctrl_value)
{
var strToCheck;
var intlen;
intlen = ctrl_value.length;
strToCheck=ctrl_value;

var checkNum = "@#$%^&*()[]?<>!~`'";
for (var i=0;i<intlen;i++)
{
	for(var j=0;j<checkNum.length;j++)
	{	
		if(strToCheck.charAt(i)==checkNum.charAt(j))
		{
		alert(" Special characters are not allowed in " + ctrl_name)
		return false;
		}
	}
}
if (intlen > 200)
{	
	
	alert("Maximum 200  characters is allowed in " + ctrl_name)
	return false;

}
return true;
}

function CheckDateval(strDateJoin)
{
if (strDateJoin=="")
	{
	return true;
	}
	//to check the date is numeric
	var num = '0123456789/';
	var i,j,found;
	found = false;
	for(i=0;i<strDateJoin.length;i++)
	{
		for(j=0;j<num.length;j++)
		{
			if(strDateJoin.charAt(i) == num.charAt(j))
			{
				found = true; break;
			}
		}
		if(found == false) 
		{
			alert("Please enter a valid date in MM/DD/YYYY format")
			return false;
		}
		if(found == true) {found=false;}
	}

	//to check the date
	strDateJoin = strDateJoin.split('/');
	var mm = parseInt(strDateJoin[0]);
	var dd = parseInt(strDateJoin[1]);
	var yyyy = parseInt(strDateJoin[2]);


//alert(mm + ":" + strDateJoin[0]);
//alert(dd + ":" + strDateJoin[1]);
//return false;


	if (isNaN(dd) || isNaN(yyyy) || isNaN(mm))
	{
		alert("Please enter a valid date");
		return false;
	}
	
	if(mm == 2 && dd > 29)
	{
		alert("Please enter a valid date");
		return false;
	}
	if(mm==2)
	{
		if(dd == 29)
		{
			if(yyyy % 4 != 0 || yyyy % 100 != 0 && yyyy % 400 == 0)
			{
				alert("Please enter a valid date");
				return false;
			}
		}
	}
	if(dd == 31)
	{
		if(mm == 2 || mm == 4 || mm == 6 || mm == 9 || mm == 11)
		{
			alert("Please enter a valid date");
			return false;
		}
	}
	if(mm > 12 || dd > 31 || dd==0 || mm==0 || yyyy==0)
	{
		alert ("Please enter a valid date in MM/DD/YYYY format")
		return false;
		
	}var len  = strDateJoin[2].length;
	if(len != 4){
			alert("Please enter Year in four digits");
			return false;
	}
	if (yyyy < 1900){
			alert("Dont enter year lesser than 1900");
			return false;
	}
	theDate = new Date();
	if (yyyy > theDate.getFullYear()){
			alert("Dont enter year more than current year");
			return false;
	}
return true;
}		

function CheckDate(strDateJoin)
{

if (strDateJoin=="")
	{
	return true;
	}
	//to check the date is numeric
	var num = '0123456789/';
	var i,j,found;
	found = false;
	for(i=0;i<strDateJoin.length;i++)
	{
		for(j=0;j<num.length;j++)
		{
			if(strDateJoin.charAt(i) == num.charAt(j))
			{
				found = true; break;
			}
		}
		if(found == false) 
		{
			alert("Please enter a valid date in MM/DD/YYYY format")
			return false;
		}
		if(found == true) {found=false;}
	}

	//to check the date
	strDateJoin = strDateJoin.split('/');
	var mm = parseInt(strDateJoin[0]);
	var dd = parseInt(strDateJoin[1]);
	var yyyy = parseInt(strDateJoin[2]);
	
	
//alert(mm + ":" + strDateJoin[0]);
//alert(yyyy + ":" + strDateJoin[2]);
//alert(strDateJoin[2].length);
//return false;


	if (isNaN(dd) || isNaN(yyyy) || isNaN(mm))
	{
		alert("Please enter a valid date");
		return false;
	}
	
	if(mm == 2 && dd > 29)
	{
		alert("Please enter a valid date");
		return false;
	}
	if(mm==2)
	{
		if(dd == 29)
		{
			if(yyyy % 4 != 0 || yyyy % 100 != 0 && yyyy % 400 == 0)
			{
				alert("Please enter a valid date");
				return false;
			}
		}
	}
	if(dd == 31)
	{
		if(mm == 2 || mm == 4 || mm == 6 || mm == 9 || mm == 11)
		{
			alert("Please enter a valid date");
			return false;
		}
	}
	if(mm > 12 || dd > 31 || dd==0 || mm==0 || yyyy==0)
	{
		alert ("Please enter a valid date in MM/DD/YYYY format")
		return false;
		
	}
	var len  = strDateJoin[2].length;
	if(len != 4){
			alert("Please enter Year in four digits");
			return false;
	}
	if (yyyy < 1900){
			alert("Dont enter year lesser than 1900");
			return false;
	}
	theDate = new Date();
	if (yyyy > theDate.getFullYear()){
			alert("Dont enter year more than current year");
			return false;
	}
return true;
}

//function to check that the data is float		
function func_checkfloat(field_Name,field_Value)
{
 var checkok="{}[]\/`~!@#$%^&*()_+|=-,;':<>"
 var allvalid=true;
 strSpecial="";
 for(i=0;i<field_Value.length;i++)
	{
		ch=field_Value.charAt(i);
		if(ch!="") 
		 {
		  strSpecial=strSpecial+ch;
		 }
		for(j=0;j<ckeckok.length;j++)
		 if(ch==checkok.charat(j))
			break;
		 if(j==checkok.length)
		  {
		   allvalid=false;
		   break;
		  }
	}
	
	var strDigits = "0123456789"
	var flag;
	
	for(i=0;i<field_Value.length;i++)
	{
	//alert(strfieldValue.substring(i,i+1))
	if(field_Value.substring(i,i+1)=="0"||field_Value.substring(i,i+1)=="1"||
			field_Value.substring(i,i+1)=="2"||field_Value.substring(i,i+1)=="3"||
			field_Value.substring(i,i+1)=="4"||field_Value.substring(i,i+1)=="5"||
			field_Value.substring(i,i+1)=="6"||field_Value.substring(i,i+1)=="7"||
			field_Value.substring(i,i+1)=="8"||field_Value.substring(i,i+1)=="9")
			{
				allvalid=true;
			}
			else
			{
				allvalid=false;
			}	
			//alert(flag)
	}
	
	if (allvalid)
	{
	 alert("Please dont enter any special characters in " + field_Name)
	}
return(allvalid)
}

function compareDates (value1, value2) {
   var date1, date2;
   var month1, month2;
   var year1, year2;

   month1 = value1.substring (0, value1.indexOf ("/"));
   date1 = value1.substring (value1.indexOf ("/")+1, value1.lastIndexOf ("/"));
   year1 = value1.substring (value1.lastIndexOf ("/")+1, value1.length);

   month2 = value2.substring (0, value2.indexOf ("/"));
   date2 = value2.substring (value2.indexOf ("/")+1, value2.lastIndexOf ("/"));
   year2 = value2.substring (value2.lastIndexOf ("/")+1, value2.length);

   if (year1 > year2) return false;
   else if (year1 < year2) return true;
   else if (month1 > month2) return false;
   else if (month1 < month2) return true;
   else if (date1 > date2) return false;
   else if (date1 < date2) return true;
   else return 0;
} 

function allowEmpty(field_Value)
{
 var len;
 var i;
 var sTemp;
 sTemp=ltrim(field_Value);
 len=field_Value.length;
 if(len==0)
 {
 //alert(field_Name + " cannot left blank.")
 return false;
 }
 return true;
}

/*-----------------------------Special Characters Validation Function------------------------------------------*/
/*-----------------------------By: Ravi Kant Srivastava--------------------------------------------*/
/*-----------------------------12/29/2005----------------------------------------------------------*/	


//     strControl   =====  messaging that has to be displayed in the message box
//     strdata      =====  Value that has to be sent from the front end form
//     criteria     =====  criteria that has to be checked
//     control      =====  control id in the form
//     i            =====  i for checking the field empty


function splCharCheck(strControl,strdata,criteria,control,i)
{
 /* Defination of criteria */
   /*
 * If 0 then perform for all
 * If string then prform check for those characters are not in the criteria
 */
 
 
 /*
 if (i == 1)
 {
  var intlen;
  intlen = strdata.length;
  if (intlen==0)
  {
  control.focus();
  control.select();
  alert(strControl + " cannot be blank");
  
  return false ;
  }
 }
*/
 var check=0;
 var x="";
 var splChars="`!@#$%^&*()_?+|\}]{[;'<,>=";
 //var splChars="<>$";
 
// if(criteria=="0")
// {
  for(i=0;i<splChars.length;i++)
  {
   for(j=0;j<strdata.length;j++)
   {
    if(splChars.charAt(i)==strdata.charAt(j))
     {           
      control.focus();
      control.select();
      alert(splChars.charAt(i)+" is not allowed in " + strControl);
      return false;
     }
   }
  }
// }
// else
// {
//  len=criteria.length;
//    
//   for(i=0;i<splChars.length;i++)
//   {
//    for(k=0;k<strdata.length;k++)
//    {
//     if(splChars.charAt(i)==strdata.charAt(k)) 
//     {
//      for(j=0;j<criteria.length;j++)
//      {
//       if(splChars.charAt(i)==criteria.charAt(j))
//       {
//        check++;
//        control.focus();
//           control.select();
//        alert(splChars.charAt(i)+" is not allowed in " + strControl);
//        return false;
//       }
//      }
//      if(check==0)
//      {            
//       control.focus();
//       control.select();
//       alert("You are using ristricted characters in " + strControl);
//       
//       return false;
//      }
//     }
//    }
//   }
//  
// }
  
 
 return true;
}
function splCharCheck2(strControl,strdata,criteria,control,i)
{

	/* Defination of criteria */
   /*
	* If 0 then perform for all
	* If string then prform check for those characters are not in the criteria
	*/
	
	//alert("hi11111");
	
/*	
	if (i == 1)
	{
	
	//alert("hi");
		var intlen;
		intlen = strdata.length;
		if (intlen==0)
		{
		control.focus();
		control.select();
		alert(strControl + " cannot be blank ");
		
		return false ;
		}
	}

*/
	var check=0;
	var x="";
	var splChars="`~!@#$%^&*()-_+|\}]{[:;'<,>.?/ 0123456789";
	//alert("hic");
	if(criteria=="0")
	{
	
	//alert("hic");
		for(i=0;i<splChars.length;i++)
		{
			for(j=0;j<strdata.length;j++)
			{
				if(splChars.charAt(i)==strdata.charAt(j))
					{											
						control.focus();
						control.select();
						//alert(strdata.charAt(j));
						//messaging Statement Modified
						alert( "Special Character - "+splChars.charAt(i)+" is not allowed in " + strControl);
						return false;
					}
			}
		}
	}
	else
	{
		len=criteria.length;
				
			for(i=0;i<splChars.length;i++)
			{
				for(k=0;k<strdata.length;k++)
				{
					if(splChars.charAt(i)==strdata.charAt(k)) 
					{
						
						for(j=0;j<criteria.length;j++)
						{							
							if(splChars.charAt(i)==criteria.charAt(j))
							{
								check++;
								//alert(splChars.charAt(i));
								//return false;
							}
						}
						//alert(check);
						if(check==0)
						{												
							control.focus();
							control.select();
//messaging Statement Modified
							alert("Special characters not allowed in " + strControl);
							
							return false;
						}
					}
				}
			}
		
	}
		
	
	return true;
}
	
	//*************** validation for scripting tags ****************************
	//*******************Astha Sharma*******************************************
	
	function scriptCharCheck(strControl,strdata,control)
	{
	    var intlen;
		intlen = strdata.length;
		if (intlen>0)
		{
		    var scriptChars="<>";
		    for(i=0;i<scriptChars.length;i++)
		    {
		        for(j=0;j<strdata.length;j++)
		        {
		            if(scriptChars.charAt(i)==strdata.charAt(j))
		            {
		                control.focus();
						control.select();
						alert( "Special Character   "+scriptChars.charAt(i)+" is not allowed in " + strControl);
						return false;
		            }
		        }
		    }
		}
		return true;
	}
	
	
	
	//**********************Function to check for only special characters  and getfield not blank*****
function func_Check_Data2(ctrl_Name,ctrl_Value)
{
//alert(ctrl_Value);

var strToCheck,len;

if(CheckEmpty(ctrl_Name,ctrl_Value))
	{
	return false;
	}
	ctrl_Value.value = Trim(ctrl_Value.value);
	
	strToCheck=ctrl_Value.value;
	len=strToCheck.length;


var checkNum=""
for(i=0;i<len;i++)
{
 for(j=0;j<checkNum.length;j++)
	{
	  if(strToCheck.charAt(i)==checkNum .charAt(j))
	   {
	    alert("Special characters are not allowed in" + ctrl_Name);
	    return false;
	   }
	   
	}
}
return true
}


//*******************************************************************************************//
//This is to trim the value of the text box
// Created by alok gupta 090406
//
//***************************************************************************************//



/*

function AllTrim()
{
if(CheckEmpty(document.theForm.AllTrim)){
return;
}
document.theForm.AllTrim.value = Trim(document.theForm.AllTrim.value);
}

*/


//********************************************************************************************//
function CheckEmpty(ctrl_Name,CONTROL)
{


//alert(CONTROL.value);


	var len;			
	var sTemp;
	sTemp=Trim(CONTROL.value); 			
	len=sTemp.length;
						
	if(len==0)
		{
			alert(ctrl_Name + " cannot be blank.");
			CONTROL.value="";
			CONTROL.focus();
			return true;
		}
	else{
		return false;
		}
}

function Trim(TRIM_VALUE)
{

		if(TRIM_VALUE.length < 1)
		{
		return"";
		}

		//alert("hui");
		TRIM_VALUE = RTrim(TRIM_VALUE);
		TRIM_VALUE = LTrim(TRIM_VALUE);
		
		if(TRIM_VALUE=="")
		{
		return "";
		}
		else
		{
		return TRIM_VALUE;
		}
} //End Function





//********************************This is used for right trim *****************************//
function RTrim(VALUE){
var w_space = String.fromCharCode(32);
var v_length = VALUE.length;
var strTemp = "";
if(v_length < 0){
return"";
}
var iTemp = v_length -1;

while(iTemp > -1){
if(VALUE.charAt(iTemp) == w_space){
}
else{
strTemp = VALUE.substring(0,iTemp +1);
break;
}
iTemp = iTemp-1;

} //End While
return strTemp;

} //End Function



//********************************This is used for left trim *****************************//
function LTrim(VALUE){
var w_space = String.fromCharCode(32);
if(v_length < 1){
return"";
}
var v_length = VALUE.length;
var strTemp = "";

var iTemp = 0;

while(iTemp < v_length){
if(VALUE.charAt(iTemp) == w_space){
}
else{
strTemp = VALUE.substring(iTemp,v_length);
break;
}
iTemp = iTemp + 1;
} //End While
return strTemp;
} //End Function

 

function allowEmpty(field_Value)
{
 var len;
 var i;
 var sTemp;
 sTemp=ltrim(field_Value);
 len=field_Value.length;
 if(len==0)
 {
 //alert(field_Name + " cannot left blank.")
 return false;
 }
 return true;
}







//================Complete Email validation Latest=======================================
//----------------BY vijay---------------------------------


function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		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;
		
 		 		
	}


//=================check dropdwonlist for SelectedIndex zero===============================
//----------------------By vijay-----------------------------------------------------
function chkDDL(OBJ,msg)
{
	if(OBJ.options.selectedIndex==0)
	{
		alert("Select "+msg+" first!!");
		OBJ.focus();
		return false;
	}
	return true;
}
//==========================Web site validation=================================================
//--------------------------By vijay-----------------------------------------------------------
function checkDomain(nname)
{
var arr = new Array(
'.com','.net','.org','.biz','.coop','.info','.museum','.name',
'.pro','.edu','.gov','.int','.mil','.ac','.ad','.ae','.af','.ag',
'.ai','.al','.am','.an','.ao','.aq','.ar','.as','.at','.au','.aw',
'.az','.ba','.bb','.bd','.be','.bf','.bg','.bh','.bi','.bj','.bm',
'.bn','.bo','.br','.bs','.bt','.bv','.bw','.by','.bz','.ca','.cc',
'.cd','.cf','.cg','.ch','.ci','.ck','.cl','.cm','.cn','.co','.cr',
'.cu','.cv','.cx','.cy','.cz','.de','.dj','.dk','.dm','.do','.dz',
'.ec','.ee','.eg','.eh','.er','.es','.et','.fi','.fj','.fk','.fm',
'.fo','.fr','.ga','.gd','.ge','.gf','.gg','.gh','.gi','.gl','.gm',
'.gn','.gp','.gq','.gr','.gs','.gt','.gu','.gv','.gy','.hk','.hm',
'.hn','.hr','.ht','.hu','.id','.ie','.il','.im','.in','.io','.iq',
'.ir','.is','.it','.je','.jm','.jo','.jp','.ke','.kg','.kh','.ki',
'.km','.kn','.kp','.kr','.kw','.ky','.kz','.la','.lb','.lc','.li',
'.lk','.lr','.ls','.lt','.lu','.lv','.ly','.ma','.mc','.md','.mg',
'.mh','.mk','.ml','.mm','.mn','.mo','.mp','.mq','.mr','.ms','.mt',
'.mu','.mv','.mw','.mx','.my','.mz','.na','.nc','.ne','.nf','.ng',
'.ni','.nl','.no','.np','.nr','.nu','.nz','.om','.pa','.pe','.pf',
'.pg','.ph','.pk','.pl','.pm','.pn','.pr','.ps','.pt','.pw','.py',
'.qa','.re','.ro','.rw','.ru','.sa','.sb','.sc','.sd','.se','.sg',
'.sh','.si','.sj','.sk','.sl','.sm','.sn','.so','.sr','.st','.sv',
'.sy','.sz','.tc','.td','.tf','.tg','.th','.tj','.tk','.tm','.tn',
'.to','.tp','.tr','.tt','.tv','.tw','.tz','.ua','.ug','.uk','.um',
'.us','.uy','.uz','.va','.vc','.ve','.vg','.vi','.vn','.vu','.ws',
'.wf','.ye','.yt','.yu','.za','.zm','.zw');

var mai = nname;
var val = true;

var dot = mai.lastIndexOf(".");
var dname = mai.substring(0,dot);
var ext = mai.substring(dot,mai.length);
//alert(ext);
	
if(dot>2 && dot<57)
{
	for(var i=0; i<arr.length; i++)
	{
	  if(ext == arr[i])
	  {
	 	val = true;
		break;
	  }	
	  else
	  {
	 	val = false;
	  }
	}
	if(val == false)
	{
	  	 alert("Your domain extension "+ext+" is not correct");
		 return false;
	}
	else
	{
		for(var j=0; j<dname.length; j++)
		{
		  var dh = dname.charAt(j);
		  var hh = dh.charCodeAt(0);
		  if((hh > 47 && hh<59) || (hh > 64 && hh<91) || (hh > 96 && hh<123) || hh==45 || hh==46)
		  {
			 if((j==0 || j==dname.length-1) && hh == 45)	
		  	 {
		 	  	 alert("Domain name should not begin are end with '-'");
			      return false;
		 	 }
		  }
		else	{
		  	 alert("Your domain name should not have special characters");
			 return false;
		  }
		}
	}
}
else
{
 alert("Your Domain name is too short/long");
 return false;
}	

return true;
}





function CheckFirstChar(ControlName,strfieldValue)
{
	
	
	var strfieldValueTrimmed = Trim(strfieldValue);
	if(strfieldValueTrimmed.substring(0,1)==".")
	{
		alert(ControlName+' can not start from . character'); 
		return false;
	}
	else if(strfieldValueTrimmed.substring(0,1)=="&")
	{
		alert(ControlName+' can not start from & character');
		return false; 
	}
	else
	{
		return true;
	}
	
	
}


















function isURL(urlStr) 
{

	if (urlStr.indexOf(" ") != -1) 
	{
		//alert("Spaces are not allowed in a URL");
		return false;
	}

	if (urlStr == "" || urlStr == null) 
	{
		return true;
	}

	urlStr=urlStr.toLowerCase();

	var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
	var validChars="\[^\\s" + specialChars + "\]";
	var atom=validChars + '+';
	var urlPat=/^http:\/\/(\w*)\.([\-\+a-z0-9]*)\.(\w*)/;
	var matchArray=urlStr.match(urlPat);

	if (matchArray==null) 
	{
		//alert("The URL seems incorrect \ncheck it begins with http://\n and it has 2 .'s");
		return false;
	}

	var user=matchArray[2];
	var domain=matchArray[3];

	for (i=0; i<user.length; i++) 
	{
		if (user.charCodeAt(i)>127) 
		{
			//alert("This domain contains invalid characters.");
			return false;
		}
	}

	for (i=0; i<domain.length; i++) 
	{
		if (domain.charCodeAt(i) > 127) 
		{
			//alert("This domain name contains invalid characters.");
			return false;
		}
	}

	var atomPat=new RegExp("^" + atom + "$");
	var domArr=domain.split(".");
	var len=domArr.length;

	for (i=0;i<len;i++) 
	{
		if (domArr[i].search(atomPat) == -1) 
		{
			//alert("The domain name does not seem to be valid.");
			return false;
		}
	}

	return true;
} 
