﻿
function savemember()
{
    var Dob;
    var NDOB;
    var DDDate;
    var leg;
    var Dod;

    Dob=form1.txtDob1.value + "/" + form1.txtDob2.value + "/" + form1.txtDob3.value

    if (!isValidDate(Dob)) 
    {
        Dob=null;
        alert("Invalid DOB");
        form1.txtDob1.value="";
        form1.txtDob2.value="";
        form1.txtDob3.value="";
        form1.txtDob1.focus();
        return false
        
    }
     Dod=form1.txtD1.value + "/" + form1.txtM1.value + "/" + form1.txtY1.value

    if (!isValidDate(Dod)) 
    {
        Dod=null;
        alert("Invalid Deposite Date");
        form1.txtD1.value="";
        form1.txtM1.value="";
        form1.txtY1.value="";
        form1.txtD1.focus();
        return false
        
    }
 
}

function IsValidDate(strDate)
{
   
	//First Parameter is Date String
	//date Format Assumed is mm/dd/yyyy (Ex : 01/01/2000 is 1st Jan 2000)
	//date has only the seperators (/) or (-)
	var year,month,day,strSep,i;
	//strDate=trim(strDate)
	//assigning the seperator
	for(i=0;i<strDate.length;i++)
	   {
	    if(strDate.charAt(i)=="/" || strDate.charAt(i)=="-")
	    {
	     strSep=strDate.charAt(i)
	     break;
	    }
	   }  
  //Seperate Year,Month,Day
	day=strDate.split(strSep)[0];
	month=strDate.split(strSep)[1];
	year=strDate.split(strSep)[2];

	var months=new Array(31,28,31,30,31,30,31,31,30,31,30,31);
	
	//Check for Leap Year & Adjust The days in Feb accordingly
		if(year % 4 == 0)
		{
			months[1]=29;
		}

	    
	//Check for valid Numbers(Day,month,year)
	if(isNaN(day) || isNaN(month) || isNaN(year))
     {
		return false;
	     }
	//Added by yogesh 28-7-2004    
	//Check For Length of Date String   		
	 if(day.length == 2 || day.length == 1 )
	  {}
     else 
       return false;
                        
	 if(month.length == 2 || month.length == 1 )
	  {}
     else
       return false;
      
     if(year.length == 4)
      {}
     else
       return false;
     
       		     
     //code added by vidya
	 
	//Check for Valid Month
	if(month > 12 || month < 1)
{
		return false;
	
	}
	//Check For Valid Days
	if(day < 1 || day > months[month-1])
{
		return false;
	}	
		for(var i=1;i<=strDate.length;i++)
		{
			if(!((i==3) ||( i==6)))
			{
				num=strDate.substring(i,i-1)
	
				if(isNaN(num)==true)
				{	
					return false;
				}
			}
			if(((i==3) ||( i==6)))
			{
				if(strDate.substring(i,i-1)!= strSep) 
				{
				return false
				}
			}
			return true
		}
		
	//added by abhay for more accuracy
	if ((strDate.charAt(8) == "/") || (strDate.charAt(10) == "/"))
	{
		return false
	}
	
	
	//	end of ad's code
	
	//added here an another condition for seperator
	//Check For Seperators
	if ((strDate.charAt(2) == "/") && (strDate.charAt(5) == "/"))
	{
		return true
	}
	else
	{
		if ((strDate.charAt(2) == "-") || (strDate.charAt(5) == "-"))
		{
			return true;
		}
		else{

			return false;
}
	}

}




 
 
