# Forms & Input Design
Forms are often where users complete their goals—signing up, checking out, submitting data. Good form design directly impacts conversion rates and user satisfaction.
---
## Contents
- Form Design Principles
- Labels and Placeholders
- Input Types
- Validation
- Required Fields
- Multi-Step Forms
- Specific Field Patterns
- Form Layout
- Submit Buttons
- Accessibility Checklist
- Sources
---
## Form Design Principles
### Evidence
Baymard's checkout research repeatedly finds that the average checkout shows roughly twice as many fields as needed, and that "too long / complicated checkout" is a top-cited abandonment reason. Treat widely quoted single figures (e.g. "81% abandon forms", "multi-step raises completion 86%") as unsourced marketing numbers — measure your own funnel instead.
### Fundamental Principles
1. **Ask only what you need** - Every field is friction
2. **Group related fields** - Logical chunking
3. **One column is usually best** - Easier scanning
4. **Clear labels** - No placeholder-only labels
5. **Smart defaults** - Pre-fill when possible
6. **Progressive disclosure** - Show fields when relevant
---
## Labels and Placeholders
### Labels
```html
```
**Best Practices:**
- Position labels above inputs (top-aligned)
- Keep labels short and clear
- Don't end with colons (modern convention)
- Associate with `for` attribute
### Placeholders
```html
```
**Placeholder Guidelines:**
- Show example format, not label
- Use gray text (but not too light)
- Don't rely on it for critical info
- Disappears—users may forget what field is
---
## Input Types
### HTML5 Input Types
```html
```
### Input Attributes
```html
aria-required="true"
autocomplete="email"
inputmode="email"
pattern="[^@]+@[^@]+\.[^@]+"
placeholder="you@example.com"
/>
```
### Autocomplete Values
```html
```
---
## Validation
### Validation Timing
| Timing | Pros | Cons | Best For |
|--------|------|------|----------|
| On blur | Immediate feedback | Can feel aggressive | Most fields |
| On submit | Low friction | Delayed error discovery | Short forms |
| On input | Real-time | Annoying while typing | Password strength |
| Hybrid | Balanced | Complex to implement | Professional forms |
### Recommended Approach
```javascript
// Validate on blur (when user leaves field)
// Don't validate while typing
// Re-validate on correction
input.addEventListener('blur', validate);
input.addEventListener('input', () => {
// Only clear errors while typing if previously invalid
if (hasError) validate();
});
```
### Error Messages
```html
Please enter a valid email address (e.g., name@example.com)
Invalid input
```
**Error Message Guidelines:**
- Place near the field (below or inline)
- Use red color + icon (not color alone)
- Be specific about what's wrong
- Suggest how to fix
- Use human-friendly language
- Don't blame the user
### Visual Error Indicators
```css
.input-error {
border-color: #dc3545;
background-color: #fff8f8;
}
.error-message {
color: #dc3545;
font-size: 0.875rem;
margin-top: 0.25rem;
display: flex;
align-items: center;
gap: 0.25rem;
}
.error-message::before {
content: "⚠️";
}
```
### Accessibility for Errors
```html
Please enter a valid email address
```
---
## Required Fields
### Marking Required Fields
```html
```
**Convention:**
- If most fields required: mark optional
- If most fields optional: mark required
- Use asterisk (*) for required
- Explain asterisk at form start
---
## Multi-Step Forms
### When to Use
- Long forms (7+ fields)
- Complex processes (checkout, applications)
- Collecting different types of info
- Reducing cognitive load
### Progress Indicator
```html
```
### Best Practices
- Show step count (Step 2 of 4)
- Allow going back to previous steps
- Save progress automatically
- Validate each step before proceeding
- Keep navigation visible
- Allow skipping optional sections
---
## Specific Field Patterns
### Password Fields
```html
At least 8 characters
One uppercase letter
One number
```
### Phone Numbers
```html
```
### Credit Cards
```html
```
### Addresses
```html
```
### Date Selection
```html
```
---
## Form Layout
### Single Column
```
┌─────────────────────────────┐
│ First Name │
├─────────────────────────────┤
│ Last Name │
├─────────────────────────────┤
│ Email │
├─────────────────────────────┤
│ [Submit] │
└─────────────────────────────┘
Best for: Mobile, most web forms
```
### Multi-Column (Use Sparingly)
```
┌──────────────┬──────────────┐
│ First Name │ Last Name │
├──────────────┴──────────────┤
│ Email │
├──────────────┬──────────────┤
│ City │ State │ Zip │
└──────────────┴──────────────┘
Use for: Related short fields
Avoid: Different topics side by side
```
### Grouping
```html
```
---
## Submit Buttons
### Button Labels
```html
```
### Button States
```html
```
### Button Placement
- Primary action on the right (or full-width on mobile)
- Cancel/back on the left
- Don't hide the submit button
- Ensure visible without scrolling
---
## Accessibility Checklist
- [ ] Labels properly associated with inputs
- [ ] Error messages linked with `aria-describedby`
- [ ] Required fields marked with `aria-required`
- [ ] Invalid fields marked with `aria-invalid`
- [ ] Errors announced with `role="alert"`
- [ ] Keyboard navigation works correctly
- [ ] Focus management on errors
- [ ] Sufficient color contrast
- [ ] Touch targets at least 44×44px
---
## Sources
- [Nielsen Norman Group - Form Design](https://www.nngroup.com/articles/web-form-design/)
- [Baymard Institute - Form Usability](https://baymard.com/blog/current-state-of-checkout-ux)
- [Luke Wroblewski - Web Form Design](https://www.lukew.com/resources/web_form_design.asp)
- [GOV.UK Design System - Forms](https://design-system.service.gov.uk/patterns/)