The sbutton below should get enabled when the value of the datebox has been changed. Why does it not work?
var sbutton = app.createButton('Set Alert').setId('sbutton').setPixelSize(250, 25).setEnabled(true);
// Button to be enabled only after date is set
var buttonenabler = app.createClientHandler().forTargets(sbutton).setEnabled(true);
eventdt.addValueChangeHandler(buttonenabler);
Check the code here https://script.google.com/d/1H6DLb8L6Qd3g55Dzn_A7ed61QvM_OcrLINDfya1i1h7JAyV_jLH7nmcq/edit
Initially, during the creation, your button is already enabled (
var sbutton = app.createButton('Set Alert')....setEnabled(true);), i.e. even if the handler is executed, the button will stay enabled. A simple demo showing how to enable a disabled button on a date box control value changing is following.Update: I reviewed your code. Seems it is a bug in GAS. The problem appears when the
setFormatfunction call is added to theDateBoxobject. See the following code reproducing the issue. If to change value in the 1st date box then the 1st button is enabled. If to change the value of the 2nd date box, the 2nd button is not enabled. the difference is only in thesetFormatcall. A bug is submitted to the issue tracker and as a workaround you can to comment thesetFormatcalls in your code.