Form UX Best Practices
Operating Mode
- - Run in text-only mode by default.
- Avoid image-led critiques, dashboards, or visual redesign directions unless explicitly requested.
- Prioritize decisions that improve completion quality, error recovery, accessibility, and trust.
Inputs Required
Collect these inputs before reviewing:
- - Form context: signup, checkout, settings, lead-gen, or other.
- Primary business goal and user goal.
- Current form source: spec, HTML, React, screenshots transcribed to text, or mixed.
- Field list with required/optional status.
- Current validation behavior (inline, blur, submit, server-side).
- Target devices (desktop, mobile, both).
Intake Questions
Ask only if essential inputs are missing. If essentials are present, proceed without questions.
- - What is the exact decision this form should support (create account, complete purchase, update settings, capture lead)?
- Which fields are mandatory to complete that decision?
- What happens after submit (success path, retry path, abandonment path)?
- Are there legal or policy constraints (age checks, billing details, consent, regional rules)?
Deterministic Review Workflow
- 1. Define task-critical outcome: state one sentence for user success and one sentence for business success.
- Map friction points: identify every extra field, ambiguous label, avoidable decision, and interruption.
- Audit field architecture: check sequence, grouping, required/optional clarity, and progressive disclosure.
- Audit validation behavior: check timing, specificity, recovery path, and consistency between inline and submit states.
- Audit accessibility semantics: labels, instructions, focus order, keyboard use, and error associations.
- Audit mobile ergonomics: input type, inputmode, keyboard hints, spacing, touch target comfort, and scroll/focus behavior.
- Audit trust signals: explain why sensitive fields are requested and place privacy assurances at decision moments.
- Produce outputs using
assets/report_template.md exactly.
Reference Loading
- - Load
references/canon.md only when you need principle-level rationale or a tie-breaker between competing form patterns. - Prefer the deterministic workflow above for execution; use canon references to justify recommendations, not to replace direct analysis.
Accessibility Checks
- - Ensure every control has a programmatic name from a visible label, not placeholder-only text.
- Ensure
label and control association via for/id or explicit wrapper label pattern. - Ensure helper text and errors are referenced by
aria-describedby where applicable. - Ensure invalid fields set
aria-invalid="true" after validation fails. - Ensure error summary (if used) links to each invalid field and receives focus after failed submit.
- Ensure tab/focus order matches visual/logical order.
- Ensure keyboard-only completion is possible without pointer interaction.
Mobile Checks
- - Use the correct keyboard hints (
type, inputmode, autocomplete, autocapitalize). - Keep label visibility persistent while typing.
- Avoid multi-column field arrangements that compress touch targets on narrow screens.
- Keep helper/error text close to field and visible without horizontal scrolling.
- Avoid forced context-switch loops (field blur -> jump -> keyboard close/open thrash).
Validation Strategy
- - Validate required presence on submit, not on first keystroke.
- Validate format either on blur or when enough characters exist to infer intent.
- Reserve real-time validation for high-value, low-noise cases (for example: password strength meter, username availability).
- Show one clear recovery action per error.
- Keep inline error copy consistent with submit-time error summary copy.
- Use error summary for multi-error forms or long forms where first error may be off-screen.
Field Design Rules
- - Prefer explicit labels above fields; do not rely on placeholders as labels.
- Mark optional fields explicitly; keep required as default unless product policy requires explicit required badges.
- Request only minimum data needed for the current decision.
- Group related fields and follow user mental model order (for checkout: contact -> delivery -> payment).
- State constraints before input when predictable (format, length, character rules).
Microcopy Rules
- - Use direct, specific phrasing that names the issue and next action.
- Avoid blame language and vague statements like "Invalid input".
- Mention accepted format when format errors are common.
- Keep tone neutral and recovery-oriented.
- Keep labels and error terms consistent (same field name in label, helper, and error).
Privacy and Trust Cues
- - Explain why sensitive information is needed at the moment it is requested.
- Place trust cues near commitment actions (submit/place order), not buried in footer text.
- Clarify consent scope and frequency for communications fields.
- Separate mandatory operational consent from optional marketing consent.
Conversion and Friction Rules
- - Remove non-essential fields from initial flow.
- Use progressive disclosure for secondary details.
- Prefer smart defaults when safe and reversible.
- Preserve entered values after failed submit.
- Minimize redundant confirmation fields unless risk justifies it.
Prioritization Rubric (P0/P1/P2)
- - P0: Blocks completion, creates legal/compliance risk, or makes the form unusable for assistive tech.
- P1: Causes significant confusion, avoidable errors, or measurable abandonment risk.
- P2: Improves clarity, speed, and polish but does not block completion.
Output Format
Always fill
assets/report_template.md sections in this exact order:
- 1. Top Issues (P0/P1/P2)
- Field-by-field rewrite
- Validation & error messaging spec
- Accessibility checklist
- Ship-ready checklist
- Optional: Ready-to-ship snippet
Optional Ship Snippet Mode
When asked to produce implementation-ready guidance:
- - Output either semantic HTML or React pseudo-code.
- Include labels, helper text hooks, error bindings, and
autocomplete attributes. - Include submit-time summary pattern when there are 2+ possible simultaneous errors.
- Keep snippet focused on form behavior and semantics, not visual styling.
Optional Static Audit Script
Use
scripts/form_audit.py for quick static checks on HTML forms.
CODEBLOCK0
Script checks:
- - Missing label mapping
- Duplicate IDs
- Missing
name attributes - Placeholder used as label
- Missing autocomplete for common fields
- Likely input type mismatches
表单用户体验最佳实践
运行模式
- - 默认以纯文本模式运行。
- 除非明确要求,否则避免以图像为主导的评论、仪表盘或视觉重新设计方案。
- 优先考虑能够提升完成质量、错误恢复、可访问性和信任度的决策。
所需输入
在审查前收集以下输入:
- - 表单场景:注册、结账、设置、线索生成或其他。
- 主要业务目标和用户目标。
- 当前表单来源:规格说明、HTML、React、转录为文本的截图或混合形式。
- 字段列表及必填/选填状态。
- 当前验证行为(内联、失焦、提交、服务器端)。
- 目标设备(桌面端、移动端、两者兼顾)。
引导性问题
仅在关键输入缺失时提问。如果关键信息已具备,则直接进行,无需提问。
- - 此表单应支持的具体决策是什么(创建账户、完成购买、更新设置、获取线索)?
- 完成该决策必须填写哪些字段?
- 提交后会发生什么(成功路径、重试路径、放弃路径)?
- 是否存在法律或政策限制(年龄验证、账单详情、同意声明、地区规则)?
确定性审查工作流程
- 1. 定义任务关键结果:用一句话描述用户成功,用一句话描述业务成功。
- 映射摩擦点:识别每一个多余字段、模糊标签、可避免的决策和中断点。
- 审计字段架构:检查顺序、分组、必填/选填清晰度以及渐进式披露。
- 审计验证行为:检查时机、具体性、恢复路径以及内联状态与提交状态之间的一致性。
- 审计无障碍语义:标签、说明、焦点顺序、键盘使用和错误关联。
- 审计移动端人体工学:输入类型、inputmode、键盘提示、间距、触摸目标舒适度以及滚动/焦点行为。
- 审计信任信号:解释为何请求敏感字段,并在决策时刻提供隐私保障。
- 严格按照 assets/report_template.md 生成输出。
参考资料加载
- - 仅当需要原则层面的理论依据或在竞争性表单模式之间进行裁决时,才加载 references/canon.md。
- 执行时优先使用上述确定性工作流程;使用规范参考资料来证明建议的合理性,而非替代直接分析。
无障碍检查
- - 确保每个控件都通过可见标签(而非仅占位符文本)获得程序化名称。
- 确保通过 for/id 或显式包装标签模式建立 label 与控件的关联。
- 确保在适用情况下,辅助文本和错误信息通过 aria-describedby 引用。
- 确保验证失败后,无效字段设置 aria-invalid=true。
- 确保错误摘要(如使用)链接到每个无效字段,并在提交失败后获得焦点。
- 确保标签页/焦点顺序与视觉/逻辑顺序一致。
- 确保无需指针交互即可仅通过键盘完成操作。
移动端检查
- - 使用正确的键盘提示(type、inputmode、autocomplete、autocapitalize)。
- 在输入时保持标签可见性持久。
- 避免在窄屏上压缩触摸目标的多列字段布局。
- 保持辅助/错误文本靠近字段,且无需水平滚动即可查看。
- 避免强制上下文切换循环(字段失焦 -> 跳转 -> 键盘关闭/打开抖动)。
验证策略
- - 在提交时验证必填项的存在,而非在首次按键时。
- 在失焦时或当输入足够字符以推断意图时验证格式。
- 将实时验证保留给高价值、低噪音的情况(例如:密码强度指示器、用户名可用性)。
- 每个错误显示一个清晰的恢复操作。
- 保持内联错误文案与提交时错误摘要文案一致。
- 对于多错误表单或首个错误可能不在屏幕上的长表单,使用错误摘要。
字段设计规则
- - 优先使用字段上方的显式标签;不要依赖占位符作为标签。
- 明确标记选填字段;除非产品政策要求显式必填徽章,否则默认保持必填。
- 仅请求当前决策所需的最少数据。
- 对相关字段进行分组,并遵循用户心智模型顺序(对于结账:联系方式 -> 配送 -> 支付)。
- 在可预测的情况下,在输入前说明约束条件(格式、长度、字符规则)。
微文案规则
- - 使用直接、具体的措辞,指出问题及下一步操作。
- 避免指责性语言和模糊表述,如无效输入。
- 当格式错误常见时,提及可接受的格式。
- 保持语气中立且以恢复为导向。
- 保持标签和错误术语一致(标签、辅助文本和错误信息中使用相同的字段名称)。
隐私与信任提示
- - 在请求敏感信息时,立即解释其必要性。
- 将信任提示放置在承诺操作(提交/下单)附近,而非埋藏在页脚文本中。
- 明确沟通字段的同意范围和频率。
- 将强制性操作同意与可选性营销同意分开。
转化率与摩擦规则
- - 从初始流程中移除非必要字段。
- 对次要细节使用渐进式披露。
- 在安全且可逆的情况下优先使用智能默认值。
- 在提交失败后保留已输入的值。
- 除非风险证明其必要性,否则尽量减少冗余的确认字段。
优先级评定标准(P0/P1/P2)
- - P0:阻碍完成、造成法律/合规风险或使表单对辅助技术不可用。
- P1:导致严重混淆、可避免的错误或可衡量的放弃风险。
- P2:提升清晰度、速度和精致度,但不阻碍完成。
输出格式
始终按以下确切顺序填写 assets/report_template.md 的各部分:
- 1. 首要问题(P0/P1/P2)
- 逐字段重写
- 验证与错误消息规范
- 无障碍检查清单
- 可发布检查清单
- 可选:可直接发布的代码片段
可选的可发布代码片段模式
当要求生成可实施的指导时:
- - 输出语义化 HTML 或 React 伪代码。
- 包含标签、辅助文本钩子、错误绑定和 autocomplete 属性。
- 当可能存在 2 个或更多同时错误时,包含提交时摘要模式。
- 保持代码片段专注于表单行为和语义,而非视觉样式。
可选的静态审计脚本
使用 scripts/form_audit.py 对 HTML 表单进行快速静态检查。
bash
python3 scripts/form_audit.py /path/to/form.html
脚本检查项:
- - 缺少标签映射
- 重复的 ID
- 缺少 name 属性
- 占位符用作标签
- 常见字段缺少自动完成
- 可能的输入类型不匹配