Note that there are some explanatory texts on larger screens.

plurals
  1. POGetting age automatically when given Date of Birth
    text
    copied!<p>I wanted to get the age of a person from his date of birth. I have a HTML code where I'm using a datepicker for dob, when I give the date-of-birth it show automatically show the age without giving submit. Please help me in finding a solution for this.</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt; DOB calculations &lt;/title&gt; &lt;link rel='stylesheet' type='text/css' href='jquery-ui.css' /&gt; &lt;script type='text/javascript' src='jquery.min.js'&gt; &lt;/script&gt; &lt;script type='text/javascript' src='jquery-ui.min.js'&gt; &lt;/script&gt; &lt;script type='text/javascript' src='jquery.js'&gt; &lt;/script&gt; &lt;script type='text/javascript' src='jquery-ui-custom.js'&gt; &lt;/script&gt; &lt;script type='text/javascript' src='jquery.ui.datepicker.js'&gt; &lt;/script&gt; &lt;script type="text/javascript"&gt; $(function() { $('#datepicker').datepicker({ changeMonth: true, changeYear: true, dateFormat: 'mm/dd/yy', //firstDay: 1, onSelect: function(dateText, inst) { dateText.split('/'); Bdate = new Date(dateText[2], dateText[0] - 1, dateText[1]); BDateArr = ('' + Bdate).split(' '); //document.getElementById('DOW').value = BDateArr[0]; Cdate = new Date; CDateArr = ('' + Cdate).split(" "); Age = CDateArr[3] - BDateArr[3]; document.getElementById('AGE').value = Age; // DOBcalc(dateText); //DOBcalc(); } }) }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;form&gt; DOB (mm/dd/yyyy): &lt;input type="text" id="datepicker" value=''&gt; Age: &lt;input id="AGE" type="text" value=""&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload