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: www/content/api.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -143,7 +143,7 @@ Note that using a [meta tag](@/docs.md#config) is the preferred mechanism for se
143
143
*`htmx.config.responseHandling:[...]` - HtmxResponseHandlingConfig[]: the default [Response Handling](@/docs.md#response-handling) behavior for response status codes can be configured here to either swap or error
144
144
*`htmx.config.allowNestedOobSwaps:true` - boolean: whether to process OOB swaps on elements that are nested within the main response element. See [Nested OOB Swaps](@/attributes/hx-swap-oob.md#nested-oob-swaps).
145
145
*`htmx.config.historyRestoreAsHxRequest:true` - Whether to treat history cache miss full page reload requests as a "HX-Request" by returning this response header. This should always be disabled when using HX-Request header to optionally return partial responses
146
-
146
+
*`htmx.config.reportValidityOfForms:false` - Weather to report input validation errors to the end user and update focus to the first input that fails validation. This should always be enabled as this matches default browser form submit behaviour
Copy file name to clipboardExpand all lines: www/content/docs.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1090,6 +1090,8 @@ Htmx fires events around validation that can be used to hook in custom validatio
1090
1090
Non-form elements do not validate before they make requests by default, but you can enable validation by setting
1091
1091
the [`hx-validate`](@/attributes/hx-validate.md) attribute to "true".
1092
1092
1093
+
Normal browser form submission alerts the user of any validation errors automatically and auto focuses on the first invalid input. For backwards compatibility reasons htmx does not report the validation to the users by default and you should always enable this option by setting `htmx.config.reportValidityOfForms` to `true` to restore the default browser behavior.
1094
+
1093
1095
### Validation Example
1094
1096
1095
1097
Here is an example of an input that uses the [`hx-on`](/attributes/hx-on) attribute to catch the
This event is triggered when an element fails validation.
568
+
This event is triggered when an element fails validation. If `preventDefault()` is invoked on the event, the reportValidity() enabled by `htmx.config.reportValidityOfForms` will not be called.
Copy file name to clipboardExpand all lines: www/content/reference.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -257,6 +257,7 @@ listed below:
257
257
|`htmx.config.responseHandling`| the default [Response Handling](@/docs.md#response-handling) behavior for response status codes can be configured here to either swap or error |
258
258
|`htmx.config.allowNestedOobSwaps`| defaults to `true`, whether to process OOB swaps on elements that are nested within the main response element. See [Nested OOB Swaps](@/attributes/hx-swap-oob.md#nested-oob-swaps). |
259
259
|`htmx.config.historyRestoreAsHxRequest`| defaults to `true`, Whether to treat history cache miss full page reload requests as a "HX-Request" by returning this response header. This should always be disabled when using HX-Request header to optionally return partial responses |
260
+
|`htmx.config.reportValidityOfForms`| defaults to `false`, Weather to report input validation errors to the end user and update focus to the first input that fails validation. This should always be enabled as this matches default browser form submit behaviour |
0 commit comments