Click here to Skip to main content
13,552,835 members
Click here to Skip to main content
Add your own
alternative version

Tagged as


13 bookmarked
Posted 22 Apr 2013
Licenced CPOL

Safe "Submit" Button

, 5 May 2013
Rate this:
Please Sign up or sign in to vote.
How to send data from HTML form to server safely


When a user on web form presses "Submit" button for sending data to web server, then the web server runs a script, query, etc. This may take uncertain time up to 1 minute. But the user sees a static page and may think: "I did not press the button or something is wrong" and press the button again many times. So the web server may get many HTML queries. This will increase CPU usage on the server and may return incorrect results.


The idea is simple.

  • Step 0 (may skip): Check the form: run function "OnSubmit" in tag FORM, check tag INPUT ("required" and "pattern" attributes).
  • Step 1: Change text on the button to "Please wait...".
  • Step 2: Disable the button.
  • Step 3: Send query.

Using the Code

Just add code to input tag:

    <input type="submit" name="Submit" value="Submit"  

önclick = "this.form.check(); this.value='Please wait...'; this.disabled=true; this.form.submit();" />    

So see 'on click' event.

Step 0. Check the Form


Step 1. Change Text on the Button

this.value='Please wait...';

Step 2. Disable the Button


Step 3. Press the Button Programmatically


Points of Interest

See also:


  • 1.1 | Added Step 0: Check form | 06.05.2013


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Ukraine Ukraine
No Biography provided

You may also be interested in...

Comments and Discussions

SuggestionClient side validation leaves button disabled Pin
Robert J. Good8-May-13 4:30
memberRobert J. Good8-May-13 4:30 
QuestionYou can do with PRG Pattern easily Pin
rjgadag5-May-13 22:55
memberrjgadag5-May-13 22:55 
GeneralMy vote of 5 Pin
M Rayhan1-May-13 1:45
memberM Rayhan1-May-13 1:45 
GeneralMy vote of 5 Pin
Jayanta Chatterjee25-Apr-13 2:39
memberJayanta Chatterjee25-Apr-13 2:39 
GeneralMy vote of 5 Pin
dgDavidGreene24-Apr-13 9:26
memberdgDavidGreene24-Apr-13 9:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02-2016 | 2.8.180515.1 | Last Updated 6 May 2013
Article Copyright 2013 by Style-7
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid