Dividing two numbers from two fields and placing it in another field

This is the code I have entered and the form doesn’t allow me to save the updated values.

frappe.ui.form.on(‘Doc_name’, {
validate: function(frm){
Destination_field=0;
d.Destination_field = flt(frm.doc.field1) / flt(frm.doc.field2);
refresh(frm);
}
});

Can anyone please help me out.

Hi @bnmahesh0017,

is Destination_field in child doctype?
is field1 and field2 in parent doctype?

No all the fields are in same parent doctype

Use below script

frappe.ui.form.on("DocType Name", {
    refresh: function(frm) {
        frm.set_value("destination_field", (frm.doc.field1 / frm.doc.field2));
    }
});

Thank you so much !