In this article we will show you how to do phone number validation in google forms is just a few simple steps using regular expressions. Simply follow the steps below.
To add the phone number question box to Google Forms, start by clicking the Add question icon on the top of the floating box on the right side of the Google Forms.
The new question box will appear. By default, it is set to Multiple choice.
Type the word “Phone number” in the question text box.
The question type will quickly change to Short answer after you type “Phone number”. Google Forms can now guess the question type using the keywords from the question you add.
Screencap of this step:
Google Forms has a response validation feature to check if the input follows a prescribed format. To enable it, click the three dots on the lower-right corner of the question box.
A drop-down list will appear. Select Response validation.
A set of response validation options will appear.
Screencap of this step:
We are now ready to set a response validation rule for phone numbers. For example, we want to specify that the phone number input should be composed of ten numbers, without any space or dash in between. So for a phone number
+1 505-644-9442
it should be inputted to the question box as
15056449442
The corresponding regular expression in Google is
[0-9]{10}
To set this regular expression rule, click the first drop-down box to change it from Number to Regular expression.
We then change the second drop-down box to select Matches.
We now finally paste the regular expression to the Pattern textbox besides the drop-down box.
Screencap of this step:
You are now done! If you check the form and type something that doesn’t follow the format you set, you will get an error.
Changing the phone number to follow the format you set will remove the error.
As you can see in the previous step, not following the correct format throws an error. The error message is Must match pattern. But what pattern? We can inform the user of the correct format through a customized error message.
In the question box with a regular expression rule set, you should notice that it also contains another small text box labeled Custom error text. For our example, we want to add the pattern so that the user can easily edit their input to follow the set format. When the input doesn’t match the format, we want the message to say
The phone number should only contain numbers without spaces in between.
We will paste this message in the remaining text box labeled Custom error text.
Screencap of this step:
You are now done! You can check the difference:
Screencap of this error:
If you enjoyed this article, you might also like our article on setting up skip logic in Google Forms or our article on how to create an invoice in Google Forms. If you are trying to set up a response email notification in Google Forms, we also suggest checking out our detailed guide.