Skip to content

Commit daab725

Browse files
committed
maint(pat-validation): Improve documentation - based on HTML standards, CSS‌ pseudo classes, formnovalidate buttons.
1 parent 9c99a2e commit daab725

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

src/pat/validation/documentation.md

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
## Description
22

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+
45

56
## Documentation
67

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.
815

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.
1017

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:
1419

15-
### The following attributes may be used.
1620

1721
| Name | Syntax | Description |
1822
| ------------- | -------------------------- | ------------------------------------------------------------ |
@@ -23,6 +27,10 @@ This pattern has several advantages over standard HTML 5 form validation:
2327
| Maximum value | `type="number" max="10"` | Check if a number is less than or equal to a given value. |
2428
| Real number | `type="number" step="any"` | Check if a number is less than or equal to a given value. |
2529

30+
31+
> **_NOTE:_** The form inputs must have a `name` attribute, otherwise the validation would not happen.
32+
33+
2634
### Error messages
2735

2836
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:
6573

6674
### Options reference
6775

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.
79+
80+
6881
| Property | Description | Default | Type |
6982
| ---------------- | -------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------- | -------------------------------------- |
7083
| disable-selector | A selector for elements that should be disabled when there are errors in the form. | | CSS Selector |

0 commit comments

Comments
 (0)