制定表单字段与校验交互规范
从表单用途审视字段必要性,明确格式、联动校验、错误文案与提交状态,产出可交付的交互规格。
完整提示词
<context>
Forms are where vague requirements turn into user frustration: a phone field that rejects valid international numbers, a name field that refuses apostrophes, a postcode required in a country without postcodes, errors shown before the person finished typing, or a whole form wiped after one server error. Each field needs a reason to exist, because every field lowers completion. A field-level spec decides type, required or optional, accepted formats and limits, normalisation (trim, case), defaults and prefills, and the exact error message, written to say how to fix the problem rather than that something is invalid. Server-side validation is the authority; client checks only help. Cross-field rules (end date after start date, at least one contact method) and conditional fields are where most bugs hide.
</context>
<task>
<form_purpose>
{{form_purpose}}
</form_purpose>
{{#context}}
<context_from_user>
{{context}}
</context_from_user>
{{/context}}
1. Challenge the field list: for each proposed field, state why it is needed and who uses the data; recommend removing or deferring fields that are not needed now.
2. Build the field table: label, type and input control, required or optional, format and allowed values, min and max length or range, normalisation, default or prefill, and help text where needed.
3. Write cross-field and conditional rules: fields shown or required only in some cases, dependencies, and uniqueness checks against existing data.
4. Specify validation timing: on blur, on submit, or as typed, per field; server-side checks; and what happens to entered data when validation fails.
5. Write every error message: specific, in plain language, saying how to fix it, and placed next to the field, plus a summary at the top for long forms.
6. Specify submission behaviour: double-submit protection, slow or failed server responses, saving drafts for long forms, and the success state.
7. List open questions with a recommended default marked as a proposal.
</task>
<constraints>
- Do not impose one country's formats for names, addresses, phone numbers, postcodes or dates unless the form serves only that country; say what the assumption is.
- Never require personal or sensitive data without a stated use; flag fields that may need consent or legal review.
- Error messages must never blame the user or expose system details.
- State that the server enforces every rule; client-side checks are a convenience.
- If the purpose is unclear, ask what the form is for before listing fields.
</constraints>
<output_format>
## Field table
Table: field, why needed, type and control, required, format and limits, normalisation, default, help text.
## Cross-field rules
Numbered rules.
## Validation timing
Table: field or rule, when checked, client or server.
## Error messages
Table: field, condition, message.
## Submission behaviour
Bullets.
## Open questions
Numbered: question, recommended default (proposal).
</output_format>可替换内容
- {{form_purpose}}
- {{#context}}
- {{context}}
- {{/context}}
分类与标签
设计创意、表单设计、交互规范、字段校验、错误提示