title: Calculate age depending upon current date & birth Date
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/4060004/calculate-age-in-javascript">Calculate age in JavaScript</a>  </p>
  </blockquote>
  
  
  
  <p>I have create form which includes Birth date,Current Date,Age text boxes,current date display by default in text box,when choose birth date I want calculate age &amp; display it into age text box..
  My Java script code:</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;script language="javascript"&gt;
  function aaa()
  {
      date= new Date();
      var d = date.getDate();
      var m= date.getMonth()+1;
      var y= date.getFullYear();
  
      document.getElementById('ddd').value=m + '/' + d + '/' + y;
  }
  function display()
  {
      var a = document.getElementById('eee').getDate.value;
      var b = document.getElementById('eee').getMonth.value;
      var c = document.getElementById('eee').getFullYear.value;
  
      //var aa= document.getElementById('eee').(this).('getDate').value;
      var e= y - c;
      {
        document.write("Ans="+e);
      }
  alret(e);
  }
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body onload="aaa();"&gt;
  &lt;form name="xyz" method="post"&gt;
      CurrentDate:&lt;input type="text" name="ddd" id="ddd" readonly="readonly"&gt; 
      BirthDate:&lt;input type="date" name="eee" id="eee"&gt;
      Age:&lt;input type="text" name="age" id="age"&gt;
  &lt;input type="submit" name="submit" value="submit" onClick="display();"&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>