Skip to content

Commit dcd9d5e

Browse files
Merge pull request #526 from SuffolkLITLab/input-validation-more-info
More specific guidance on input validation
2 parents 932469b + 603287a commit dcd9d5e

File tree

1 file changed

+52
-8
lines changed

1 file changed

+52
-8
lines changed

docs/style_guide/question_style_validation.md

Lines changed: 52 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,46 +17,90 @@ form.
1717

1818
Examples of places validation can be helpful:
1919

20-
* to limit a Social Security Number input to 4 digits (and prevent
20+
* to limit a Social Security Number input to 4 digits (and prevent
2121
a user from typing additional digits, revealing a private number)
2222
* to ensure an ID number or account number is correctly entered
2323
* to limit the length of fields that will be placed on a PDF form
2424
with limited space
2525
* to validate a strictly defined format, such as an email address
26-
* to provide password complexity rules (always display complexity
26+
* to provide password complexity rules (always display complexity
2727
rules before the user starts typing a password)
2828

29+
### Focus validation on true errors, not edge cases
30+
31+
Use validation to catch information that cannot be correct, rather than unlikely but
32+
possible inputs. For example, reject an impossible date (e.g. a 13th month) or an
33+
obviously invalid format, but don't arbitrarily cap a number field
34+
(like number of children or income) if a higher value is technically feasible.
35+
36+
* Overly strict rules based on "common" assumptions will eventually fail for some users
37+
(creating false errors)
38+
* It's safer to trust users on unusual inputs and let them review those answers on their own.
39+
2940
## When to avoid input validation
3041

3142
Avoid validation when:
3243

33-
* the rules for the correct format are inconsistent in the real world. For example:
44+
* validation helps the user avoid an unlikely answer, but not a technically invalid answer.
45+
For example: avoid validation of how many children, income amount, or other situations
46+
where the user could enter what we think, now, is a comically large number.
47+
* the rules for the correct format are inconsistent in the real world. For example:
3448
case numbers or docket numbers
3549
* rules are strict but may be unpredictable, such as for a phone number that
3650
might be provided in an international format you do not have the ability to
3751
code for specifically
3852
* users may have a valid reason for using the input to communicate with the clerk,
3953
such as providing a short note in addition to the value, like (my cousin's number)
4054

55+
In general, we are careful about adding validation rules to predict every scenario a
56+
user might encounter where they could possibly make a mistake. We save validation for
57+
high-stakes input choices (a missing digit in the only contact method the user provides) or
58+
that would cause the form to be invalid.
59+
60+
> Validation rules rarely account for a much-needed wide range of exceptions and custom rules.
61+
> They are often based on common assumptions that will eventually fail for some users —
62+
> we just don't know for how many. - Smashing Magazine
63+
4164
## How to write good validation messages
4265

4366
* Use error messages to tell users how to fix problems, not describe what is wrong.
4467
* Don't blame the user for the problem.
4568
* Try reading the error message aloud. Make sure it is specific to the actual error.
4669
* You may need to write multiple error messages to handle different error states.
4770

71+
## Let users keep going when you can
72+
73+
Don't trap users with validation: Never implement validations in a way that completely
74+
blocks the user from moving forward without any option. For example, avoid disabling
75+
the "Next" or "Submit" button entirely just because some field doesn't perfectly meet
76+
a rule. Users might be right (or have a valid but unanticipated answer) and still be
77+
prevented from proceeding. Research shows that such hard stops – like disabled submit
78+
buttons due to validation – often lead to 100% abandonment for those users.
79+
80+
Provide overrides for edge cases: If you must enforce a validation rule that could erroneously
81+
catch some legitimate inputs, give users a safety valve. One approach is to allow an override--
82+
for instance, a small "Confirm and continue" link or button when the system flags something that
83+
the user insists is correct. This way, a user with a rare scenario (say, an address that your
84+
system doesn't recognize, or an uncommon name with multiple special characters) isn't completely
85+
blocked. They can confirm their entry and move on, and you'll at least capture the data for manual
86+
review if needed. It's better to collect the input and double-check it later than to reject a
87+
real user outright due to a strict rule.
88+
4889
## Further reading
90+
91+
* [UK.gov guidance on validation](https://design-system.service.gov.uk/patterns/validation/)
4992
* [UK.gov guidance on writing error messages](https://design-system.service.gov.uk/components/error-message/#be-clear-and-concise)
5093
* [UK's NHS guidance on writing error messages](https://service-manual.nhs.uk/design-system/components/error-message)
5194
* https://uxplanet.org/how-to-write-a-perfect-error-message-da1ca65a8f36
95+
* [A Complete Guide To Live Validation UX (Smashing Magazine)](https://www.smashingmagazine.com/2022/09/inline-validation-web-forms-ux/)
5296

5397
## "Soft" validation: how to use warnings
5498

55-
Sometimes you dont want to stop the user, you just want to let the user know to double check their answer. Unfortunately, we still dont have a good model for this and are looking for evidence-based research on it. Here are some unverified possibilities.
99+
Sometimes you don't want to stop the user, you just want to let the user know to double check their answer. Unfortunately, we still don't have a good model for this and are looking for evidence-based research on it. Here are some unverified possibilities.
56100

57-
* For important choices, you can use a follow up screen to warn someone about their choice. If its not that important, you might consider skipping the validation completely.
101+
* For important choices, you can use a follow up screen to warn someone about their choice. If it's not that important, you might consider skipping the validation completely.
58102
* For radio buttons, you might only show the warning if they choose something you want to draw their attention to.
59103
* A modal pop-up is one way to tell the user something might be wrong. Some people find those confusing and annoying.
60-
* Another option is to show warning text under the field as soon as the user starts answering. You would hide it as soon as the answer looked good. You would allow the user to continue either way. With this method, some people may feel theyre being scolded before theyve been given a chance to put in their answer.
61-
* A possible way around the issue is to offer an I know what Im doing checkbox that reveals a different field - one that wont stop the user.
62-
* Alternatively, you could have a review screen for the user before they submit their final answer and show the warning there. Its not immediate, but they could choose to edit the answer at that point.
104+
* Another option is to show warning text under the field as soon as the user starts answering. You would hide it as soon as the answer looked good. You would allow the user to continue either way. With this method, some people may feel they're being scolded before they've been given a chance to put in their answer.
105+
* A possible way around the issue is to offer an "I know what I'm doing" checkbox that reveals a different field - one that won't stop the user.
106+
* Alternatively, you could have a review screen for the user before they submit their final answer and show the warning there. It's not immediate, but they could choose to edit the answer at that point.

0 commit comments

Comments
 (0)