which is better client/server validation

Posted by Jameschowdare under JavaScript on 12/3/2009 | Views : 2647 | Status : [Member] | Replies : 7
which is better client/server validation




Responses

Posted by: Sagarchavada on: 3/25/2019 [Member] Starter | Points: 25

Up
0
Down
IF you go for JQuery,MVC,JSON then,
Client Side:
You want to validate input on the client side first because you can give better feedback to the average user. For example, if they enter an invalid email address and move to the next field, you can show an error message immediately. That way the user can correct every field before they submit the form.
If you only validate on the server, they have to submit the form, get an error message, and try to hunt down the problem.
(This pain can be eased by having the server re-render the form with the user's original input filled in, but client-side validation is still faster.)
Server Side:
You want to validate on the server side because you can protect against the malicious user, who can easily bypass your JavaScript and submit dangerous input to the server.
It is very dangerous to trust your UI. Not only can they abuse your UI, but they may not be using your UI at all, or even a browser. What if the user manually edits the URL, or runs their own Javascript, or tweaks their HTTP requests with another tool? What if they send custom HTTP requests from curl or from a script, for example?
Not allowing for that is not only naive from a security standpoint, but also non-standard: a client should be allowed to send HTTP by whatever means they wish, and you should respond correctly. That includes validation.
Server side validation is also important for compatibility - not all users, even if they're using a browser, will have JavaScript enabled.
LINK:
http://www.ifourtechnolab.com/asp-dot-net-enterprise-content-management


Jameschowdare, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vuyiswamb on: 12/4/2009 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
it depends what you asking for. When asking a Question please explain Clearly. In ASP.NET is good to do Validation on the Client side using java-script, its faster.

Thank you for posting at Dotnetfunda

Vuyiswa Maseko

Thank you for posting at Dotnetfunda
[Administrator]

Jameschowdare, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Muhilan on: 12/4/2009 [Member] Starter

Up
0
Down
Client Validation is faster because client side we can intimate the error , no Postback will happen.

ex.

The User name is Mandatory field. without entered the Username the user click before send to the server , we can do client slide validation for better performance.

Jameschowdare, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Virendradugar on: 12/4/2009 [Member] [MVP] Silver

Up
0
Down
Well, it depends on your requirement. You can go for Client Side validation, if your Javascript is not disabled as it will give you better performance.

But if Client side validation is disabled, then it better to go for Server side validation.

Best Practice is to do it on both the side.

Thanks,
Virendra Dugar

Jameschowdare, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Jameschowdare on: 12/7/2009 [Member] Starter

Up
0
Down
if client disable his browser then how to do validation

Jameschowdare, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vuyiswamb on: 12/7/2009 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
That is why i like Validating from the server side.

Thank you for posting at Dotnetfunda
[Administrator]

Jameschowdare, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Chikul on: 12/11/2009 [Member] Bronze

Up
0
Down
Hi Jameschowdare ,

We can use both. .In my knowledge Server side validation is more important.

Lets check 1 example.

There is one Text box, which should allow integer. (In DB its int)
Now use Javascript to validate it "onblur".
Then user can sees the error right away and can correct it before submits the request.

Lets we gave some Invalid value(char) and Click on submit.
So here if we'll not validate on Server side then it'll throw error.

So we should always validate any fields with requirements on the server to be in safe side.

Regards,
Chikul

Jameschowdare, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response