简体   繁体   中英

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.

Use JavaScriptconfirm() 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM