Click here to Skip to main content
15,907,392 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I need information that when to use Javascript validation and server side validation .Is there any rules defined or is there any books which clarifies above.
Posted

There are no rules. It depends on how important the validation is. Validation in JavaScript can be faster, because it comes without any HTTP requests which heavily depend on traffic. For JavaScript, it just does not matter.

As to the importance, this is more serious. JavaScript can be 1) switched off by the user, 2) eavesdropped or forged with some malware. Server validation is free from this problem (unless the server host is infected, which is no so likely :-)): even though the HTTP request can be forged, it cannot harm anything on the server, because server-side validation can filter out any signs of malicious activity, and, say, just silently ignore malicious request.

I personally experienced some attack, very trivial yet very harmful (could easily turn your server host into a zombie distributing spam), which I very reliably blocked by server-side validation. This is such an important case, that every Web developer should understand it. Please see my past post on the topic: unable to send mail , it showing the error in below code .[^].

—SA
 
Share this answer
 
Comments
[no name] 8-Aug-14 7:55am    
My vote of 5
Well explained but as a good programmer we must do validations in both side right ?
Sergey Alexandrovich Kryukov 8-Aug-14 13:35pm    
It depends...
Thank you, Sibeesh.
—SA
sp_suresh 11-Aug-14 0:07am    
thank you very much .....
Sergey Alexandrovich Kryukov 11-Aug-14 1:02am    
You are very welcome.
Good luck, call again.
—SA
When you have any validations on your web page, Then Java script is highly appreciated. As it is working from client side, the speed of validations will be much faster when comparing to server side validations. But ensure that you are not validating any confidential data's in javascript, I mean in client side.
Server side is good for database and huge data population validations in web page.


Please refer this link[^]


Happy Coding :)
 
Share this answer
 
Please go through the following link,
http://stackoverflow.com/questions/162159/javascript-client-side-vs-server-side-validation[^]

As a programmer you must do the validation both in client side and server side. In that you can avoid some % of errors you may face.
 
Share this answer
 
Hi,

You book on ASP.Net validation :http://msdn.microsoft.com/en-us/library/ms972961.aspx[^]

Look javascript validation can easily be by pass but server side is not so put very low level validations in Javascript and High Level validation in Server side

Low Level Validation : Data Type check, Exists Check etc
High Level Validation : Dependency Check,Value check using your business logic etc
 
Share this answer
 
Comments
sp_suresh 11-Aug-14 0:27am    
thanks ...

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900