0

I have the following JS code in my HTML, but no confirm windows shows when pressing the button - what is wrong?

<script>
    function confirmSubmit() {
    var retVal = confirm("Are you sure you want to cancel");
    if (retVal == true) {
        return true;
    } else {
        return false;
    }
}
</script>

And within a form the following button

<form action="{% url 'listing' listing.id %}" method="POST">    
     <button name="end" type="submit" class="btn btn-danger" onClick="return confirmSubmit();">Close listing</button>
</form>
2
  • Try changing onClick to onclick
    – Vsjain
    Mar 18 at 13:37
  • I tried that, but still don't work...
    – Alexander
    Mar 18 at 14:50
0

Solved it - I had to put the script inside the layout.html's heading tag!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .