Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Confirmation on submit

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.

like image 626
codedude Avatar asked Nov 29 '22 17:11

codedude


1 Answers

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.

like image 187
BalusC Avatar answered Dec 04 '22 12:12

BalusC