Confirmation before submitting form using jQuery -


i trying add confirmation before form submitted using jquery. found nice example in stack overflow question form confirm before submit can't work.

jquery:

$(function() {     $('form#delete').submit(function() {         var c = confirm("click ok continue?");         return c;     }); }); 

template:

<form id="delete" action="{% url 'item_delete' item.id %}" method="post">{% csrf_token %}     <input class="floatright" type="submit" value="delete" /> </form> 

how can achieve this?

you submitting form , after checking confirm, need inverse

js:

$(function() {    $("#delete_button").click(function(){       if (confirm("click ok continue?")){          $('form#delete').submit();       }    }); }); 

html:

<form id="delete" action="{% url 'item_delete' item.id %}" method="post">{% csrf_token %}     <input id="delete_button" class="floatright" type="button" value="delete" /> </form> 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -