@Senthil_Kumar check this script, also you can see browser console for error log
frappe.ui.form.on("Task", "budgeted_amount", function(frm) {
calculate_excess_amount(frm);
});
frappe.ui.form.on("Task", "purchased_amount", function(frm) {
calculate_excess_amount(frm);
});
var calculate_excess_amount = function(frm) {
var excess_amount = flt(frm.doc.purchased_amount) - flt(frm.doc.budgeted_amount);
frm.set_value("excess_amount", excess_amount);
}