When clicking on new lead, it is showing the age of last visited lead there

Hi
I want auto calculated age when DOB is entered. The code is working fine, but when clicking on new lead, it is showing the age of last visited lead there.


The code i used it -
frappe.ui.form.on(‘Lead’, {
refresh: function (frm) {

},
onload: function (frm) {
	if(frm.doc.dob){
		$(frm.fields_dict['age_html'].wrapper).html("AGE : " + get_age(frm.doc.dob));
	}
}

});

frappe.ui.form.on(“Lead”, “dob”, function(frm) {
if(frm.doc.dob){
var today = new Date();
var birthDate = new Date(frm.doc.dob);
var age_str = get_age(frm.doc.dob);
$(frm.fields_dict[‘age_html’].wrapper).html("AGE : " + age_str);
}
});

var get_age = function (birth) {
var ageMS = Date.parse(Date()) - Date.parse(birth);
var age = new Date();
age.setTime(ageMS);
var years = age.getFullYear() - 1970;
return years + " Year(s) " + age.getMonth() + " Month(s) " + age.getDate() + " Day(s)";
};

Please suggest any solutions.