I have made a form using Google Apps Script’s Ui Services and put it as a gadget inside a Sites page. The form has a SubmitButton. In the doPost I save the form data to a Google spreadsheet.
How can I validate form data before it gets saved?
- I couldn’t use doPost because it clears the UI.
- I thought of using regular Button and handle validation and saving in a ServerClickHandler but I cannot get the all form data in e.parameter.
What is the right way to do this?
I did it using the second approach I mentioned above using the click handler of a button instead of a submit button on a form. The problem was that for a strange reason the handler throws an exception if the callback element (panel or a grid) has a multi-select Listbox. If the listbox is removed, the handler works as it should. I posted it as an issue to Google forum.
I am still interested to see if this can be done in the doPost method using submit button and a form panel. I think it would be possible if we could prevent doPost from clearing out the UI somehow.