confirm before submit form php 1

confirm before submit form php

onclick="return confirm('Are you sure you want to submit this form?')"

Here is what the above code is Doing:
1. We’re creating a new variable called “form” and setting it equal to the form element with the ID of “myForm”.
2. We’re adding an event listener to the form variable that listens for the “submit” event.
3. When the submit event is triggered, we’re calling the function “confirmDelete”.
4. The “confirmDelete” function is going to return a boolean value of either true or false.
5. If the user clicks “OK”, the function will return true and the form will be submitted.
6. If the user clicks “Cancel”, the function will return false and the form will not be submitted.

Similar Posts