This is an adaptation of Paul Guerette’s great solution for locking all fields on a form. We have tweaked the function to look out for button objects by checking the ui.oneOfChild.className of the current object.
In addition we have include some security aspects of this earlier solution.
Thanks to Jono for spotting an error in the HASH function, where an error was thrown if the “str” variable was null. This is now corrected.
I have also taken the opportunity to explain a bit more about calling functions that are in script objects.