| How can I ask the user to confirm before submitting a form? |
| User Opinions |
|
No users have voted.
|
|
Thank you for rating this answer.
|
Sometimes you want to make sure the user really intended to click on a form button, or even on an ordinary link. Examples include "delete" buttons. In the most important cases, you should solve this problem by adding an additional "confirmation" page to the dynamic web application that receives the form submission. Since not all users have Javascript enabled in their browsers, there is a chance that your confirmation prompt will not be seen before the form is submitted or the link is followed. In situations where this possibility is acceptable, or you cannot modify the CGI, PHP, ASP or other script accepting the form submission, you can use a simple Javascript technique to confirm the click. If the user does not click "Yes," the form submission or link navigation is canceled. See below for a simple example of a link with a confirmation prompt: <a href="scarypage.html"
onClick="return confirm('Do you really want to follow ' +
'this link? It's really scary!');">
Vist Our Scary Page</a>
Also, see below for an example of a form submission with a confirmation prompt: <form method="POST" action="submit.php">
<input type="hidden" name="accountid" value="23948234">
<input type="submit" name="delete"
value="Delete My Account"
onClick="return confirm(
'Are you sure you want to delete your account?');">
</form>
|
| Visitor Comments |
|
No visitor comments posted. Post a comment
|
| Attachments |
|
No attachments were found.
|