Form Validation Before Submission

后端 未结 1 767
忘掉有多难
忘掉有多难 2021-01-20 01:49

I can\'t get my form to validate before it is submitted to my spreadsheet. Once I click submit it does nothing...

I also am not sure how to validate the Date to make

1条回答
  •  有刺的猬
    2021-01-20 02:11

    I've been spending a lot of time on form validation and I ended up with 2 possible solutions that work pretty well but since I can't decide which one is the best I use sometimes the first... and sometimes the second...

    I'll show the idea of both solution, make your choice.

    1. The 'logical' one : use client validation to enable the submit button and a few other client handler validations to show/hide warning labels near the fields that have to be filled. It works great but I must admit it can be tricky to write the script for it and needs quite a lot of code. (see examples in these post among others : Form validation on fields and FileUpload
      Form validation using client handler : why does input sequence order change the result?
    2. Use a server handler like you did in your code but replace the "createEvent" button with an intermediate button that instead of sending you directly to the event creation function calls a "fake" function that shows a summary of the requested data in a HTML widget with a nice looking presentation and another button that one use to confirm the event creation (and actually create the event) making a sort of 2 steps confirmation that is definitely user friendly. (and includes a way to go back one step to change/append the submitted data.

    Both solution as I already said have pro and cons, the second one is just probably easier to write a script for it.

    feel free to comment and/or ask for further details if the references I mentioned are not clear enough.


    EDIT : here is an example of the 2cond approach and the spreadsheet with the included script (read only, make a copy to view/edit script and change the spreadsheet ID in the script if you want to run your own version)) The instructions are in french but it shouldn't be too hard to translate ... sorry about that :-) The SS has a marter sheet where you can define the question in the form and the script generates a custom form. There are tools to count responses, print log sheet per day and send confirmation emails.

    0 讨论(0)
提交回复
热议问题