Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

pros/cons of having javascript submit forms

Status
Not open for further replies.

blexman

Programmer
Jul 18, 2001
34
0
0
CA
I am doing some form valdiation using javascript. What are the pros/cons of having javascript sub the form vs ASP doing it ?

thanks
hanton
 
to submit a form called "myform" from javascript, do the following :
Code:
getElementById("myform").submit();
Water is not bad as long as it stays out human body ;-)
 
JS Pros: The processing occurs on the client side so it doesn't take up more of the server's processing cycle. The submission process can be halted by returning a false value to the onSubmit event of the form tag, allowing the user to fix the information without having to re-generate the page.
JS Cons: If the client has javascript turned off, it won't error check. If someone wants to overflow your SQL query or for some reason enter any form data that you would not normally allow all they need to do is copy the html source, make some minor alterations, and submit it to your site, thus sending incorrect data (buffer overflows, nested select statements, etc). Also, users can view source on your javascript and try to find loopholes you may have missed.

ASP Pros: The data is checked after it is submitted back to the server but before it is submitted to db, so the JS Cons will not have an effect because illegitimate data will be caught before it is used. Since the code is not viewable by users they will not know how you go about your error checking, and thus will have a greater difficuly finding any ackdoors in your error checking.
ASP Cons: Since this is happening after the form submission, if you want the user to fix any mistakes they had in a form they filled out you have to re-generate the form with the values they filled in. The error checking also is occuring server side, slowing down IIS ever so slightly.

Thats what I could think of off the top of my head, hope it helps,
-Tarwn --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
For my next trick I will pull a hat out of a rabbit (if you think thats bad you should see how the pigeon feels...) :p
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top