title: Javascript Calculate Age from HTML input date type
body: <p>I am trying to calculate age using Javascript. The choose their date of birth from an HTML date input type and his/her age should be displayed. How can Javascript use the HTML Date input type data and calculate age?</p>
  
  <p>Below is the HTML</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;title&gt; Sample Date of Birth Registration&lt;/title&gt;
  
  &lt;script type="text/javascript" src="formiteration6.js"&gt;&lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;h1&gt;Birth Registration&lt;/h1&gt;
  &lt;hr /&gt;
  &lt;form id ="inputFrom"&gt;
   &lt;label for="size_1"&gt;D.O.B:&lt;/label&gt;&lt;input type="date" name="size" id="birthDate" value="dd/mm/yy"  /&gt;
   &lt;input type='button' onclick='regBirth()' value='Add new person' /&gt;
   &lt;/form&gt;
   &lt;hr /&gt;
  &lt;table id="details"&gt;
    &lt;tr&gt;
    &lt;th&gt;Date of Birth&lt;/th&gt;
    &lt;th&gt;Age&lt;/th&gt;
    &lt;/tr&gt;
  
  &lt;/table&gt;
  &lt;h4&gt;Statistics&lt;/h1&gt;
  &lt;hr /&gt;
  &lt;h5&gt;&lt;b&gt;Total Count:&lt;/b&gt;&lt;/h5&gt;
  &lt;p id="count"&gt;&lt;/p&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>And Javascript is here</p>
  
  <pre><code>var allPeople = [];
  
  function regBirth() {
      'use strict';
      var myArray = {};
  
      var actualDob = myArray.actualBirthDate;
      actualDob = document.getElementById('birthDate').value
  
      allPeople.push(myArray);
  
      var inputForm = document.getElementById("inputFrom").reset();
      var tabularForm = document.createDocumentFragment();
      var tablerow = document.createElement('tr'); 
  
      var dob = document.createElement('td');
      dob.innerHTML = actualDob;
      tablerow.appendChild(dob);
  
      tabularForm.appendChild(tablerow); 
      document.getElementById("details").appendChild(tabularForm);
  
      var totalPeople = allPeople.length;
  
      document.getElementById("count").innerHTML=totalPeople;
  }
  </code></pre>