Calculate age with Javascript from Bootstrap datepicker
<p>I want to calculate an age based on the user's input on datepicker (I used Bootstrap datepicker) and output it to an age text field.</p>

<p>I tried searching through it, but I've got no luck. My date format is in <code>yyyy-mm-dd</code>.</p>

<p>Here is my HTML for datepicker and age text field.</p>

<pre><code>&lt;label for="bday"&gt;Birthday:
    &lt;div id="datepicker" class="input-group date"  style="width:200px;"&gt;
        &lt;input id="dob" name="date" class="form-control" type="text"  /&gt;
        &lt;span class="input-group-addon"&gt;&lt;i class="glyphicon glyphicon-calendar"&gt;&lt;/i&gt;&lt;/span&gt;
    &lt;/div&gt;
&lt;/label&gt;
&lt;label for="age"&gt;Age
    &lt;input class="form-control" type="text" id="myage" style="width:200px;" /&gt;
&lt;/label&gt;
</code></pre>

<p>And here is the Javascript:</p>

<pre><code>$(function () {
    $('#dob').datepicker({
        format: "yyyy-mm-dd",
        autoclose: true,
    }) .on('changeDate',function(event){
        // compute age here.. I think?
    });
});
</code></pre>