dob = new Date($("#DateOfBirth").val()) var today = new Date(); var age = Math.floor((today - dob) / (365.25 * 24 * 60 * 60 * 1000)); $('#txtAge').val(age + ' years old');