required
required
Most fundamental validator: rejects empty values. For groups (radio, checkbox), the rule applies once and is satisfied by any group member being checked.
<input data-validation="required" name="login"> Ten built-in validators, listed alphabetically. Each is a { init, validate, errorMessage? } object you spread into validatorDeclarations when constructing FormValidator.
“Text-like input” below means any of:
text,password,tel,url,search,number,date,time,datetime-local,month,week,color,range,hidden. An<input>without atypeattribute defaults totext.
<input type="file">is supported byrequiredonly — for real file validation (size, MIME, count) write a custom validator.
required required
Most fundamental validator: rejects empty values. For groups (radio, checkbox), the rule applies once and is satisfied by any group member being checked.
<input data-validation="required" name="login"> minLength minLength(3)
Counts UTF-16 code units to match the native minlength attribute. Empty values pass — combine with required to forbid empty.
<input data-validation="minLength(3)" name="username"> maxLength maxLength(20)
Counts UTF-16 code units, matching native maxlength.
<input data-validation="maxLength(20)" name="title"> pattern pattern(\\d{4})
The regex is auto-anchored (^(?:…)$) so it must match the entire value, matching native pattern. Empty value passes — combine with required to forbid empty.
<input data-validation="pattern(\d{4})" name="pin"> equalsTo equalsTo(password)
Cross-field equality, e.g. password confirmation. Strict === — Unicode normalization is not applied ('café' in NFC and NFD are not equal). Intentional, so password matching is byte-exact.
<input id="password" type="password" data-validation="required">
<input data-validation="equalsTo(password)" type="password" name="confirm"> checkedCount checkedCount(1,3)
Group min/max for checkboxes / radios. ,N means up to N. N, means N or more. The error attaches to the context (here the fieldset) because group errors don’t belong to any single member.
<fieldset data-validation-context="checkedCount">
<input type="checkbox" name="opts" value="a" data-validation="checkedCount(1,3)">
<input type="checkbox" name="opts" value="b">
<input type="checkbox" name="opts" value="c">
<input type="checkbox" name="opts" value="d">
</fieldset> numeric numeric
Rejects unparseable input (validity.badInput, plus a defensive parse-side check). Empty value passes — compose with required.
<input type="number" data-validation="required;numeric" name="amount"> min min(10) / min(2026-01-01)
The bound is parsed in the input’s own format — for type="date", ISO-8601 (YYYY-MM-DD); for type="time", HH:MM[:SS]; etc. Empty / bad-input passes (compose with required / numeric).
<input type="date" data-validation="required;numeric;min(2026-01-01)" name="start"> max max(100) / max(2026-12-31)
Same types as min. Empty / bad-input passes (compose with required / numeric).
<input type="number" data-validation="required;numeric;max(100)" name="percentage"> step step(0.5) / step(7, 2026-01-05) / step(900, 09:00)
Step is in the input type’s natural unit: number = 1; date = 1 day; time = 1 second; month = 1 month; week = 1 week; datetime-local = 1 second. Default base is 0 — except week, where the base is the Monday of 1970-W01 so the grid lines up with valid week values. Compared within 1e-9 to absorb FP error. Empty / bad-input passes (compose with required / numeric).
<input type="time" data-validation="required;numeric;step(900)" name="slot">