Google Forms – How to Validate a Date

data validationdategoogle-forms

Google Forms include the possibility to perform some sort of validation on user input for checkboxes and text; the functionality is available very easily both via the UI and the API. Unfortunately, it seems that there no support for any sort of validation on date input fields. The API does not include it, and I don't see any callback/trigger that I can use for this purpose.

More specifically, my form contains a field in which the user is requested to input their birthdate, and the form can be submitted only if their age lies in a certain interval (otherwise an error message of some sort should be displayed, possibly directly below the input field like in the other existing validations). All this should go in a form created with the Google Form creation UI.

Is there a way to do it? I don't mind if this is a client-only check, since this is not mission-critical and my users won't be experts actively trying to break it. And, of course, I don't mind writing Javascript / Google Apps script code for this purpose.

(Incidentally, in the API documentation for a DateItem I don't even see a function to return the date that the user has chosen, which I would need to implement this.)

Related:

Best Answer

In contrary to Short text, paragraph and checkbox questions, Google Forms doesn't have a way to validate input through date questions. Ref. Set rules for your form

There is no way to add client-side code to the respondent view of Google Forms but you could create a web form that submit form data to the Google Form back-end.

Some "early" approaches copy the source code of the respondent view, adapt it to add client-side features like input validation of change the form presentation. Example of this "early approach" How to style Google Forms. NOTE: This works with the "old" Google Forms.

Another alternative is to create a totally independent web form. You could use the Google Apps Script HTML Service for this or other tools.

NOTE: In a strict sense, Google Forms doesn't have an API contrary as occurs with Google Sheets .