コンテンツへスキップ

Lesson 69: Presence and format checks

English

Two more validation checks

  • Lesson 40 had the range, length and type checks. Here are two more.
  • A presence check: something was entered (the field is not empty).
  • A format check: the data has the right pattern, for example 2 letters then 4 digits.
Check Example What it rejects
presence a name must be entered an empty line
format ID like AB1234 A12345, ab1234, AB12C4
length ID has 6 characters AB123
check digit the last digit is worked out from the others (lesson 41) a mistyped code

ログインまたはアカウント作成

IGCSE, A-Level & AP