I have a form that submits information to a database. How can I make it so that when I click the submit button, I get an alert that asks me if I really want to submit it and when I click "Yes" it continues and if I click "no" it does not submit the information.
Use JavaScript confirm()
function.
<input type="submit" onclick="return confirm('Are you sure?')">
If the user chooses Yes, it will return true
and the button's default action (submitting the form) will continue as usual. But if the user chooses No, it will return false
and the button's default action will be blocked.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With