Google forms do not provide a way to validate common input types out of the box such as an email text field.
To ensure that a text field takes only emails, you will need to use the validation option.
In this article, we will look at setting rules for one of the commonest input types: emails.
👉 How to add custom validation
Following these steps to add validation rules to your text field:
- Click on the vertical three dots next to the Required toggle button.
- Click on Response Validation from the menu that appears to reveal the rules section.
- From the rules section select Regular expression from the first dropdown menu.
- From the dropdown next to that select the Matches option.
The GIF above also provides a visual of how to do this.
The Pattern field is where we will be adding our actual rules in regex.
👉 Email address validation
Now that we have seen how to add validation rules, we will now look at the regex we need for pattern matching.
In the pattern textbox add the following regex:
Do note that this only checks the email structure and does not mean the provided email exists.
You can also set an error message in the Custom error textbox. For example "Please provide a valid email address".
This will be shown to the user whenever they provide an invalid email.
Here is another article for you 😊 "BrainFuck Interpreter using method chaining"