Js event on datetime change

hello . I want to run some code on changing a datetime field .
I used the to_date: function(frm) … in js
it works , but the code runs many times when I slide the time slider, how to run the code only once ?

Hi. Unfortunately, the slider updates the field for each fraction of the slider therefore it will call the function that number of times (i.e. a 5 minute change will result in 5 calls). Your options are to either not use the slider, or check if the field value differs from the value in the database during validation.

I’m not sure but I guess this could be a workaround
In field changing event use

clearTimeout(frm.timeId);
frm.timeId = setTimeout(callback, interval);

and set interval to some proper value like 500