Click here to Skip to main content
11,577,643 members (41,076 online)
Click here to Skip to main content

Tagged as

Safe "Submit" Button

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

Introduction

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.

Background

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

 this.form.check(); 

Step 1. Change Text on the Button

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

Step 2. Disable the Button

 this.disabled=true;    

Step 3. Press the Button Programmatically

 this.form.submit();    

Points of Interest

See also:

History

  • 1.1 | Added Step 0: Check form | 06.05.2013

License

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

Share

About the Author

Style-7
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    Rant Rant    Admin Admin   

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

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.150603.1 | Last Updated 6 May 2013
Article Copyright 2013 by Style-7
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid