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.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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.