Google Forms
Senior 6 · ICT
Google Forms
Lesson 2 of 4
25 min
The Science Club at a school in Huye registers members at the start of each term. Returning members only need to choose this term's project; new members must also give their interests and confirm that a parent agrees. One long form would ask returning members questions that do not apply to them, and many would give up halfway. A well-built form shows each person only the questions that apply, checks the answers as they are typed, and thanks them when they finish.
In this lesson you build that form step by step: sections, branching, validation, a confirmation message, testing and publishing.
Definition
Section: a page of a Google Form. The respondent sees one section at a time and moves on with Next.
Branching (Google calls it Go to section based on answer): sending the respondent to a different section according to the option they chose in a multiple-choice or dropdown question. Example: "Yes" skips to section 3, "No" goes to section 2.
Regular expression (regex): a pattern that describes allowed text. Example: ^S[1-6]-[0-9]{4}$ means "S, a digit 1 to 6, a hyphen, then exactly four digits".
A. Title, description and section 1
^S[1-6]-[0-9]{4}$. In Custom error text, type "Write it like S6-0412".B. Sections 2 and 3
C. Branching
Draw the branching before you build it. The arrows must reach Submit from every starting answer, and no section should be reachable only by mistake.
A pattern that rejects good answers is worse than no pattern, so test it with real and wrong examples first. This short JavaScript program, run with node, tries the two patterns used in the club form. Google Forms uses its own regex engine (RE2), but simple patterns like these behave the same way.
// Test the two validation patterns before putting them in the form
const phone = /^07[2389][0-9]{7}$/; // Rwandan mobile: 072, 073, 078 or 079 + 7 digits
const adm = /^S[1-6]-[0-9]{4}$/; // admission number such as S6-0412
for (const t of ["0788123456", "078812345", "0748123456", "+250788123456", "0788 123 456"])
console.log(t.padEnd(15), phone.test(t));
for (const t of ["S6-0412", "s6-0412", "S7-0412", "S6-412"])
console.log(t.padEnd(15), adm.test(t));Output:
0788123456 true
078812345 false
0748123456 false
+250788123456 false
0788 123 456 false
S6-0412 true
s6-0412 false
S7-0412 false
S6-412 falseThe phone pattern accepts a ten-digit number starting 072, 073, 078 or 079, and rejects one digit too few, an unknown prefix, the international form and spaces. If the club wants to accept +250 numbers too, the pattern must be widened; the custom error text should tell respondents which form to use.
| Validation type (short answer) | Example rule | Use |
|---|---|---|
| Number | Between 13 and 25 | Age |
| Text | A contact email address | |
| Length | Maximum character count 300 | A short motivation statement |
| Regular expression | Matches ^S[1-6]-[0-9]{4}$ | Admission number |
For Checkboxes the rules are select at least, at most or exactly a number of options, for example "choose at most 2 projects".
OnlineComputerTips: How to Use Logic in Google Forms: Go to Section Based on Answer. Watch where the option sits in the question's ⋮ menu and how each answer is pointed at a section; then compare with step 7 above.
Worked example 1: find the branching bug
A tester chooses No on question 4, fills in section 2, and is sent straight to Submit without seeing section 3. What is wrong?
Worked example 2: required or not?
Should "Which areas interest you?" in section 2 be required?
forms.gle address that fits in a WhatsApp message or on a poster.<> option when sending), which gives an <iframe> you paste into the page.Warning
Editing a live form changes it for everyone at once. If you rename or delete an option after 200 people have answered, the old answers keep the old text and the summary splits into two groups. Finish testing before you publish, and if you must change a live form, add new options rather than renaming old ones.
Tip
Test every path, not just one. A form with branching has as many routes as there are combinations of branching answers. With one Yes or No branch there are two routes: test both, every time you change the form.
Check: your form passes when both routes reach section 3, a new member cannot submit without consent, and s6-412 is rejected with a helpful message.
Practice
MPC-6.^07[2389][0-9]{7}$ accept: (a) 0731234567; (b) 07312345678; (c) 0751234567?^[A-Z]{3}-[4-6]$Sources and credits
This lesson adapts CC BY-SA material and is shared under CC BY-SA 4.0.