Sub topic 6
5. Error Prevention
This chapter assumes you understand what a user interface is and have everyday experience with websites and apps. Basic HTML is optional. You will examine how design can stop mistakes before they happen, rather than only explaining mistakes afterward.
What error prevention means
Error prevention is the practice of designing an interface so that users are less likely to make mistakes. A mistake can happen because a user misunderstands an option, enters data in the wrong format, clicks the wrong control, or performs a risky action accidentally.
A helpful design prevents errors at the source:
- Remove invalid choices from a list.
- Show the format that an input requires.
- Use sensible defaults.
- Ask for confirmation before an action that is difficult to reverse.
- Disable a command when it cannot work.
- Check information before submitting it.
Error prevention is different from error recovery. Prevention stops or reduces a mistake. Recovery helps the user understand and fix a mistake after it occurs. Good interfaces use both.
Common prevention patterns
Constrain the available choices
A form should not ask users to remember rules that the interface can enforce. For example, a date picker can prevent users from choosing a date before today when they are scheduling a future appointment. A select menu can show only valid shipping countries instead of accepting any text.
Constraints must match the real task. A constraint that blocks a legitimate action is itself a usability problem.
Show requirements before submission
Users should see input requirements while they are completing a form. Labels, examples, and appropriate input controls reduce guessing. HTML attributes can also let the browser perform basic checks.
<label for="email">Email address</label>
<input id="email" name="email" type="email" required autocomplete="email">The type="email" attribute tells the browser to expect an email address. The required attribute prevents an empty submission. The autocomplete attribute lets the browser offer a known email address, reducing repeated typing.
These checks do not replace server-side validation. A server must validate submitted data because browser checks can be bypassed.
Use safe defaults
A default value is a value selected or entered before the user takes action. Defaults should reflect the most common safe choice, not the choice that benefits the system owner.
For example, a newsletter checkbox should not be selected if subscribing is optional. A country field can default to the user's known country when that information is reliable. A destructive option should never be the default.
Confirm high-impact actions
Confirmation dialogs are useful when an action can delete data, send a message to the wrong person, or create a costly commitment. They are harmful when they interrupt ordinary, reversible actions so often that users click through without reading.
A better pattern is often to make the action reversible. After deleting a document, show an undo action for a short period. This gives users control without forcing a confirmation dialog every time.
let items = ["Invoice", "Report", "Notes"];
function removeItem(index) {
const [removed] = items.splice(index, 1);
return function undo() {
items.splice(index, 0, removed);
};
}
const undo = removeItem(1);
// items is now ["Invoice", "Notes"]
undo();
// items is back to ["Invoice", "Report", "Notes"]A prevention review
When reviewing an interface, ask:
- What mistakes are likely at each step?
- Can the interface make an invalid choice impossible?
- Are requirements visible before the user submits?
- Are defaults safe and appropriate?
- Can a risky action be undone?
- Does prevention block valid tasks?
Exercise
Exercise
A payment form lets users type any card number and reports “Payment failed” only after submission. Which prevention changes would improve it?
Show answer
Show the expected card-number format, validate the number while it is entered, identify the payment method when possible, preserve the user's input after failure, and explain what must be corrected before another submission.