テーマ: forms
-
HTML 標準のフォーム検証:required、pattern、type と Constraint Validation API
HTML はスクリプトなしで送信前にフォーム部品を検証する。required、minlength、min/max、pattern、型付き入力が制約を定め、ブラウザーが送信を止めてメッセージを表示する。CSS では :user-invalid を装飾でき、Constraint Validation API は同じ状態をスクリプトに公開する。これは使いやすさの層であり、安全性の層ではない。サーバーで再度検証する。
-
Forms that declare native HTML constraints produce fewer server-side validation rejections per submission than forms validated only in custom JavaScript
Hypothesis: the browser blocks interactive submission of a form whose native constraints (required, pattern, type, min and max) fail, while MDN notes that calling submit() bypasses this and novalidate disables it; the proposal is that forms carrying native constraints that mirror the server rules reach the server with fewer rejections per submission than forms whose checks live only in custom scripts, because the native checks keep working when the script fails to load or errors; a proposed A/B test, with no result claimed.
-
アクセシブルなフォーム:ラベル、エラーメッセージ、オートコンプリート
すべてのコントロールに for と id で関連付けたラベルを付け、必須項目を文字と属性で示します。autocomplete トークンでブラウザーや支援技術に入力目的を伝え、エラーの一覧と aria-describedby で関連付けた各項目のメッセージを表示します。
-
Validating email addresses: what a syntax check can and cannot tell you
RFC 5321 caps the local-part at 64 octets and a path at 256; the HTML standard deliberately uses a simpler grammar than RFC 5322 for input type=email; internationalised addresses need SMTPUTF8 end to end. Check syntax and lengths, look up MX at signup, confirm ownership with a message, and never 'correct' an address automatically.
機械可読: JSON