You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/pat/validation/documentation.md
+20-7Lines changed: 20 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,18 +1,22 @@
1
1
## Description
2
2
3
-
This pattern provides a simple but powerful form validation beyond what HTML5 offers.
3
+
This pattern provides form validation based on the HTML standard and offers extended functionality like custom error messages and extra validation rules.
4
+
4
5
5
6
## Documentation
6
7
7
-
The validation pattern is triggered by a single class `pat-validation` on the form tag. The rest is handled mostly with standard HTML5 validation attributes.
8
+
The validation pattern is triggered by a single class `pat-validation` on the form tag.
9
+
The rest is handled mostly with standard HTML validation attributes.
10
+
11
+
This patterns offers:
12
+
13
+
- extra validation rules like checking for equality or checking is one date it after another.
14
+
- custom error messages.
8
15
9
-
This pattern has several advantages over standard HTML 5 form validation:
16
+
Since it is based on the HTML standard you can still use the `:valid`, `:invalid` and `:out-of-range` CSS pseudo classes.
10
17
11
-
- it supports older browsers
12
-
- it uses simple documented HTML markup to allow non-browser-specific styling of error messages
13
-
- it supports extra validation rules
18
+
You can use any HTML form validation attributes but here are some examples:
@@ -23,6 +27,10 @@ This pattern has several advantages over standard HTML 5 form validation:
23
27
| Maximum value |`type="number" max="10"`| Check if a number is less than or equal to a given value. |
24
28
| Real number |`type="number" step="any"`| Check if a number is less than or equal to a given value. |
25
29
30
+
31
+
> **_NOTE:_** The form inputs must have a `name` attribute, otherwise the validation would not happen.
32
+
33
+
26
34
### Error messages
27
35
28
36
Error messages are inserted into the DOM as `em` elements with a `message warning` class.
@@ -65,6 +73,11 @@ Error messages can also be overridden on a per-field basis, for example:
65
73
66
74
### Options reference
67
75
76
+
> **_NOTE:_** The form inputs must have a `name` attribute, otherwise the validation would not happen.
77
+
78
+
> **_NOTE:_** If you need to exclude a submit button from form validation - like a cancel button which actually submits - add the `formnovalidate` attribute to the button.
0 commit comments