title: Display age on selecting date from date picker
body: <p>I have written following jQuery for calculating age when user selects date from date picker and the focus of <code>textbox(#dobfield)</code> is lost then the calculated age should get displayed on <code>textbox (#age)</code>.</p>
  
  <pre><code> function GetAge(dateString) {
        var today = new Date();
        var birthDate = new Date(dateString);
        var age = today.getFullYear() - birthDate.getFullYear();
        var m = today.getMonth() - birthDate.getMonth();
        if (m &lt; 0 || (m === 0 &amp;&amp; today.getDate() &lt; birthDate.getDate())) {
            age--;
        }
        return age;
    }
  
    $(document).ready(function() {
  
        $("#dobfield").onblur(function() {
            var dob = $("#dobfield").val().trim();
            var calculatedDob = GetAge(dob);
            $("#age").text(calculatedDob);
        });
    });
  </code></pre>
  
  <p>The html is as</p>
  
  <pre><code>        &lt;input aria-required="true" id="dobfield" class="form-control" required="" type="text" onclick="css()"&gt;
          &lt;input type="text" id="age" class="form-control" required&gt;
  </code></pre>
  
  <p>The above code is not working!!!</p>
  
  <p>Please help !!!</p>