HTML - How to do a Confirmation popup to a Submit button and then send the request? HTML - How to do a Confirmation popup to a Submit button and then send the request? django django

HTML - How to do a Confirmation popup to a Submit button and then send the request?


The most compact version:

<input type="submit" onclick="return confirm('Are you sure?')" />

The key thing to note is the return

-

Because there are many ways to skin a cat, here is another alternate method:

HTML:

<input type="submit" onclick="clicked(event)" />

Javascript:

<script>function clicked(e){    if(!confirm('Are you sure?')) {        e.preventDefault();    }}</script>


I believe you want to use confirm()

<script type="text/javascript">    function clicked() {       if (confirm('Do you want to submit?')) {           yourformelement.submit();       } else {           return false;       }    }</script>


Use window.confirm() instead of window.alert().

HTML:

<input type="submit" onclick="return clicked();" value="Button" />

JavaScript:

function clicked() {    return confirm('clicked');}