document.getElementById("my_form").addEventListener("submit", function() {
if (confirm("Are you sure to submit")) {
return true;
} else {
return false;
}
});
By adding a few lines of code, you can ensure that your users confirm their submission before the form is actually submitted. In the above code example,
The minimal code that can be used to show the confirmation box before the form submits is as below.
if (confirm("Are you sure to submit")) {
return true;
} else {
return false;
}
If you are using jQuery, you can use the below code
$("my_form_id").submit(function() {
if (confirm("Are you sure to delete it")) {
return true;
} else {
return false;
}
});
0 Comments