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
This is essentially the same bug as #396 but expressed in a different way with a concrete example.
Suppose I have a simple flask app that supports GET and POST of test.html with the following page
<!DOCTYPE html><htmllang="en"><body><formaction="{{ request.path }}" method='post'><labelfor="choose">Would you prefer a banana or cherry?</label><inputid="choose" name="like" required><button>Submit</button><ahref='#' hx-post="{{ request.path }}">hx-post</a></form></body><scriptsrc="https://unpkg.com/htmx.org@1.2.1"></script></html>
If I do not enter anything and press submit, the form is not submitted
If I enter cherry, the form can be submitted.
However, if I leave the input blank and press hx-post, the form is submitted regardless of the required property of <input id="choose" name="like" required>.
The root cause is that hx-post does not trigger the submit event of the form and bypasses HTML form validation. If hx-post is designed NOT to dispatch a submit event, there should be a way to easily do that. A hyperscript trick might help.
The text was updated successfully, but these errors were encountered:
This is essentially the same bug as #396 but expressed in a different way with a concrete example.
Suppose I have a simple flask app that supports
GET
andPOST
oftest.html
with the following pageIf I do not enter anything and press
submit
, the form is not submittedIf I enter cherry, the form can be submitted.
However, if I leave the
input
blank and presshx-post
, the form is submitted regardless of therequired
property of<input id="choose" name="like" required>
.The root cause is that
hx-post
does not trigger thesubmit
event of theform
and bypasses HTML form validation. Ifhx-post
is designed NOT to dispatch asubmit
event, there should be a way to easily do that. A hyperscript trick might help.The text was updated successfully, but these errors were encountered: