Compare duration of different fields

Hi! How do I make a client script returning an error if est trip duration is not equal to est working duration + est rest time + est break time.

I tried this script, but it’s not working:

	refresh(frm) {
	    frappe.ui.form.on('Delivery', 'validate', function(frm) {
	        if(frm.doc.est_working_duration + frm.doc.est_rest_time + frm.doc.est_break_time != frm.doc.est_travel_duration){
	            frappe.throw({
                    title: __('Error'),
                    indicator: 'red',
                    message: __('Est Working Duration + Est Rest Time + Est Break Time should be equal to Est Travel Duration')
                });
                validated = false;
            }
	    });
	}
});

How do you compare if duration matches between fields?

@mehmehly duration are stored in seconds so you just do the math using normal fields . try :

if ( frm.doc.est_working_duration+frm.doc.est_rest_time+frm.doc.est_break_time!=frm.doc.est_travel_duration)

also you can use server script here if you want to validate durations before insert .

I found the error, it was in the very beginning :sweat_smile: Thanks so much @bahaou