skip to Main Content

Html – Swap a form on error, or redirect on success using HTMX

I have a login form marked up like this: <div id="login_form" hx-ext="response-targets"> <form action="/login" method="POST" hx-boost="true" hx-target="#login_form" hx-target-400="#login_form" hx-swap="innerHTML"> ... <button type="submit">Log in</button> </form> </div> When there's an error, backend returns the form with outlined errors, with 400 status code…

VIEW QUESTION

Html – Is it possible to trigger / submit a form by clicking on a div?

My current code is: <form id="search-form" hx-post="/search-api" hx-target="#search-result"></form> <div class="search-wrapper"> <div class="material-icons search-button md-8 md-light" role="button" type="submit" form="search-form">search</div> <div class="search-bar-wrapper"> <textarea name="search" type="text" class="search-bar" id="search-bar" form="search-form" placeholder="search" oninput="autoResize(this)"></textarea> </div> </div> <div id="search-result"></div> I can't submit the form when I click…

VIEW QUESTION

“How can I show an error only once when a user submits invalid info on a form in HTML/Django?”

may someone tell me how to avoid to have the error message shown 2 times? I'd like to keep the top error message, but on red. https://files.slack.com/files-pri/T07EFKXHR-F058SR427RA/image.png html: <form hx-post="{{ request.path }}" class="modal-content p-4" enctype="multipart/form-data"> <div class="modal-header"> <h5 class="modal-title">Ingresa tu…

VIEW QUESTION
Back To Top
Search