I am creating an application in django and I have the next problem: I have a form in html with a submit button, but I want to show a confirmation dialog to select Yes or No before processing the information. How could I do it?
This is my form code:
<form id="id" method="post" action="/y/b/" enctype="multipart/form-data">
    {% csrf_token %} 
    {{ form.as_p }}
    <input class="btn btn-primary" type="submit" name="submit" value="A" />
</form>
Thank you so much!
Have onsubmit attribute in your form tag like this if you just want a confirmation from user.
https://jsfiddle.net/yetn60ja/
<form id="id"
    method="POST" action="/y/b/"
    enctype="multipart/form-data"
    onsubmit="return confirm('Do you really want to submit the form?');"
>
    <input class="btn btn-primary"
        type="submit" name="submit" value="A"
    />
</form>
EDIT: Or try below code
<form id="id"
    method="POST" action="/y/b/"
    enctype="multipart/form-data"
>
    <input class="btn btn-primary"
        type="submit" name="submit" value="A"
        onclick="return confirm('Do you really want to submit the form?');"
    />
</form>
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With