Reputation: 2821
I have a Google Form where I would like to make sure the user has entered the email address correctly. I would simply like to compare the two fields and throw an error if they are not the same.
Email Address:
---
Confirm Email Address:
---
Is this possible with a script in Google Forms?
Upvotes: 1
Views: 1801
Reputation: 31310
No. It's not possible with a script. Apps Script for Google forms is for creating/editing the layout and content of a form. The only script that can run from a form is an onSubmit()
trigger. And you can't intercept the submission before it's sent. There is no way to use a script during the input of a form. All you can do is change the data after it's already submitted. But in that case, you might want to inform the user that what they submitted is wrong. So you'd need to email them.
If you want to use the existing HTML of your Google Form in order to create a new form file (NOT a Google Form), there is a way to do that, which might save you some time writing HTML for a new form. You can view the live form, then use the Browsers ability to view the source code, and copy out everything between the <form></form>
tags. Customize that, then save it to it's own file. But, it's still going to be a separate file. You would need to find a way to host the new form. You could probably host it right from your Google drive, just like the Google Form. The form submission from the Google Form can be duplicated in a custom HTML file. The form submission happens from this HTML "code":
<form action="https://docs.google.com/forms/d/theID_of_the_Form/formResponse" method="POST" id="ss-form" target="_self" onsubmit="">
So, you can write custom HTML, CSS and JavaScript; put that HTML into it's own file; use the existing Form ID to submit the data; host the new HTML file; and then use the link from the new HTML file to email to people.
It would be a matter of personal preference as to whether you want to customize a form this way, or use Apps Script HTML Service and write code that appends data to a spreadsheet. Either way, you need to be able to style some CSS, and write some JavaScript.
Upvotes: 2