Back to main page!

Knowledgebase Home Knowledgebase Home
Search the Knowledgebase Browse by Category
How can I ask the user to confirm before submitting a form?
User Opinions
No users have voted.

How would you rate this answer?
Helpful
Not helpful
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
Related Questions
Attachments
No attachments were found.

Home | Web Design | Print Advertisements | Banner Design | Other Services


Copyright © 2003 Digital Arts Group @ FrankGonzalez.com. All Rights Reserved
About Us | Disclaimer | Privacy Policy | Terms of Use | Design Team | Sitemap