htmx 4.0 is under construction — migration guide

hx-validate

Validate before submitting request

The hx-validate attribute will cause an element to validate itself by way of the HTML5 Validation API before it submits a request.

Syntax

<input hx-post="/submit" hx-validate="true">

Only <form> elements validate data by default, but other elements do not. Adding hx-validate="true" to <input>, <textarea> or <select> enables validation before sending requests.