Can anyone tell me how to validate a date in dd/mm/yyyy format
<p>Below is my code...</p>

<pre><code>/**
* Check whether the values entered in the date fields are in dd/mm/yyyy format 
* and whether the dd, mm and yyyy values are valid
**/
function validateDateFormat(obj)
{
 var dtStr=obj.value;
 var year;
 var day;
 var month;
 var leap=0;
 var valid=true;
 var oth_valid=true;
 var feb=false;
 var validDate=true;
 var Ret=true;

  if(obj.readOnly==false)
  {
    if(dtStr!="" &amp;&amp; dtStr!=null)
    {
        year=dtStr.substr(6,4);
        month=dtStr.substr(3,2);
        day=dtStr.substr(0,2);

        if(year=="0000" || year&lt;1900 || month=="00" || day=="00" || dtStr.length&lt;10)
        {
            validDate=false;
        }

        if(validDate==true)
        {
            leap=year%4;

         if(month=="02")
         {
                feb=true;
         }


        if(leap==0 &amp;&amp; month=="02")
            {
                if(day&gt;29)
                {
                    valid=false;
                    feb=true;
                }
            }

            else if(month=="02" &amp;&amp; day&gt;28)
            {    
                valid=false;
                feb=true;
            }

            if(feb==false)
            {       
                if(month=="03" || month=="01" || month=="05" || month=="07" || month=="08" || month=="10" || month=="12")
                {
                    if(day&gt;31)
                    {                       
                        oth_valid=false;
                    }
                }

                else if(month=="04" || month==06 || month=="09" || month=="11") 
                {
                    if(day&gt;30)
                    {                       
                        oth_valid=false;
                    }
                }

                else
                {
                    oth_valid=false;
                }

            }
        }
    }   

     if(valid==false || oth_valid==false || validDate==false)
    {
        alert("Please enter the valid date in the dd/mm/yyyy Format only");
        obj.value="";
        obj.focus();
        Ret=false;
    }
    return Ret;
   }
}
</code></pre>
