Products
Services
Contact Us

Scripts: Javascript :: Forms :: Library Article #6

Developer's Section

Learn to Display Confirmation Messages when Submitting a form
By: Erobo Team Member

Hire a Developer for Related Work / Installation | $55 hr
Rating:  | Rate It:   
Average Votes: (1650)
Favorites:

In this quick tutorial I will explain how to display a simple confirmation message in a form. This can help you to have an additional security step before doing a critical operation (Modifyng or Deleting data).

It is sometimes very important to have some security that can help users protect their data by having an additional GUI step before submitting data with critical information. Thus, a confirmation message before submitting a form will make you think twice before making any changes to the current data.

Here is an example of the confirmation message:

My Form

We can accomplish this in 2 steps:

Step 1:
Create javascript: (put this on top of the page or on the header)

 Code Snippet 1

function displayConfirmation()
{
    var doSubmit = confirm("Do you wish to continue ?") 
    
    if(doSubmit)
    {
        return true;
    }
    else
    {
        return false;
    }
}
</script>

Step 2:
Create the form and use the onsubmit method:

 Code Snippet 2

<form name="Display_Conf" action="rer.html" 
onsubmit="return displayConfirmation();">
<table border="1" style="border-collapse: collapse">
<tr>
     <td>My Form</td>
</tr>
<tr>
     <td><input type="Submit" value="Submit My Form"></td>
</tr>
</table>
</form>

So, hopefully you will find it useful!


See other Scripts in Forms

 

Submit Your Scripts:


System Message:
  • Your Javascript script has been sent. Please allow 48 hours for processing.


If you would like to have your Javascripts published in this section please fill out
the form below:
*Your Name or Username:
Home Town:
*Email:
*Description and Code:
*Enter Code shown
to the right:

[ Refresh Image ]