Form Validation

Form validation encapsulates code to validate text input & textarea form elements. When field looses focus it validates content and if necessary display error message below the field. For that it utilises form events of input, blur & invalid.

Predefined error messages can overwritten with params named after VaidityState object keys.

Examples (1)
Example Code

<as-form-validation type-mismatch="Dette felt er af den forkerte type">[form input / form textarea]</as-form-validation>
Properties (7)
Property name Description Type
value-missing Optional: defaults to "This field is required" string
too-long Optional: defaults to "This field is too long" string
too-short Optional: defaults to "This field is too short" string
range-overflow Optional: defaults to "This field has a number that is too big" string
range-underflow Optional: defaults to "This field has a number that is too small" string
type-mismatch Optional: defaults to "This field is the wrong type" string
pattern-mismatch Optional: defaults to "This fields value does not match the pattern" string
Events (2)
Event name Description Example value
as-form-validation:success Fired when field validation returns no error. Has detail object. {fieldid: 'myemail'}
as-form-validation:error Fired when field validation error. Has detail object {fieldid: 'myemail', type: 'valueMissing', message: 'This field is required'}
Files