I have a form with many fields. When the user picks his date of birth, I want the form to automatically calculate the age based on the dob and today and report that result in the age field.
See what i implemented again:All, Thanks for your response.But I still have issue implementing that. See my code and correct :
<p> Date of Birth:
<input type="date" name="dob" value="" id="dob" placeholder="Date of Birth" required="required"/></p>
<script> function agefinding()
{
var birthDay = document.getElementById("dob").value;
var DOB = new Date(birthDay);
var today = new Date();
var age = today.getTime() - DOB.getTime();
age = Math.floor(age / (1000 * 60 * 60 * 24 * 365.25));
// alert(age);
//return age;
document.getElementById('age').value = age;
}</script>
<p> Age:
<input type="numeric" name="age" value="" id="age" placeholder="Age" required="required"/></p>