Chuyển đến nội dung
Skillpedia
Website và giao diện (frontend)75k · #2859

form-validation

Skill này làm gì

Skill này kiểm tra việc kiểm tra dữ liệu form để các thông báo lỗi được liên kết với đúng trường. Skill dành cho lập trình viên xây form có trường bắt buộc hoặc trường được kiểm tra.

Khi nào nên dùng

  • ✓Khi form hiển thị lỗi mà người dùng trình đọc màn hình không tìm thấy.
  • ✓Khi các trường bắt buộc không được đánh dấu cho công cụ hỗ trợ.
  • ✓Khi một lỗi chỉ hiện viền đỏ mà không có thông báo nào.

Liên kết skill

https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/form-validation/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/form-validation/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Bạn có thể làm cho thông báo lỗi của form tôi rõ ràng với người dùng trình đọc màn hình không?”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Agent kiểm tra xem văn bản lỗi có được liên kết với từng trường và các trạng thái không hợp lệ có được đánh dấu không. Agent gợi ý thông báo nội tuyến, đánh dấu bắt buộc và fieldset cho các lựa chọn nhóm.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

Validate forms accessibly

Inaccessible form validation leaves screen reader users unable to understand what went wrong and how to fix it, causing frustration and form abandonment.

Quick Reference

  • Associate error messages with fields using aria-describedby
  • Use aria-invalid to indicate validation state
  • Mark required fields programmatically with required or aria-required
  • Provide inline error messages near the field
  • Don't rely solely on color to indicate errors
  • Keep help text and error text linked to the field throughout validation

Check

Verify forms have client-side validation with accessible error messages linked to form fields via aria-describedby. Do not flag React forms just because they omit method or action when onSubmit clearly handles submission client-side. Confirm required fields are exposed programmatically and grouped controls use fieldset and legend.

Fix

Implement validation with clear error messages, aria-invalid states, and aria-describedby references to error text. For client-handled forms, improve validation semantics without forcing server-post patterns that the component is not using. Add required or aria-required where appropriate and use <fieldset> with <legend> for grouped choices.

Explain

Explain how accessible form validation improves user experience and ensures all users can understand and correct errors.

Code Review

Review templates, server-rendered HTML, and shared components that output markup related to Validate forms accessibly. Flag exact elements, attributes, and routes where the rendered HTML violates the rule. Check that help text and error text are both included in aria-describedby and that required state is exposed in markup, not only in visual styling.


For full implementation details, code examples, and framework-specific guidance, see references/rule.md.

Rule page: https://frontendchecklist.io/rules/html/form-validation

Câu hỏi thường gặp

aria-describedby làm gì?

Nó liên kết một trường với văn bản lỗi hoặc văn bản trợ giúp, để trình đọc màn hình đọc thông báo cùng với trường.

Chỉ màu sắc có nên báo lỗi không?

Không. Skill nói không nên chỉ dựa vào màu sắc để báo lỗi.

Skill có đánh giá form React giống vậy không?

Skill nói không nên đánh dấu form React chỉ vì thiếu method hoặc action khi chúng xử lý gửi form bằng mã.

Chi tiết

Mô tả gốc của tác giả

Use when reviewing templates, rendered HTML, or shared components related to Validate forms accessibly. Validate the final browser-facing markup, not just the source framework abstraction. Distinguish between browser-posted forms and client-handled React forms so you do not over-report missing `method` or `action` as accessibility defects.

repo: thedaviddias/Front-End-Checklist

Độ phổ biến

Sao GitHub
75k
Vị trí xếp hạng
#2859
Giấy phép
MIT
Cập nhật
31/10/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự