Ann Nacional
Ann Nacional

Reputation: 75

What validation is better to practice - Server-side or Client side validation?

I am making a new system and wanted to know what kind of validations to use for a more convenient coding and a secure system.

Should I use Server-side or Client side validation?

Upvotes: 2

Views: 1959

Answers (3)

Darshan
Darshan

Reputation: 59

I second, 'The1nk' points. But one additional point is we have to support the user in-terms of fast-responds for mistakes and purposeful attempts, thus the client-side validation is effective.

Definitely you must go with the Server-side validation and for client side validations, just like in the past you are not required to go with the hard-coded Javascript validations (though can go for complex data validations). If you wanted to use some simple validation there are many features available in HTML 5 which you can use like below,

Must required text fields: add html input attribute 'required' (note: no value for this attribute)

Specific types text fields: there are lots of different types of 'type' attribute values are added in HTML 5 like email, number, date, etc... can use them to validate those fields (there are additional attributes also available for those input types, for example for number min and max attributes)

Some useful links

HTML form input types

HTML form attributes

Since this is pure HTML the long term concern (What if the user disable the JS in browser?) with JS can be somewhat addressed. But, Keep in mind "There are NO Silver Bullet in Software Engineering" - Fred Brooks.

Upvotes: 0

Sunil Pachlangia
Sunil Pachlangia

Reputation: 2061

I will go with both sides validation. As both have there separate significance. If you just put the validation only on client side then someone can make your life miserable. And if you just put server side validation then for any error every time client have to fill complete data to server and then only he/she will be able to know the error. So if you just show the error right there just by clicking then it will be good for both of you as you don't have to handle erroneous data every time.

Upvotes: 1

The1nk
The1nk

Reputation: 702

You absolutely need server side validation as the client can't force data in with it in place.

Client side is optional, as without it bad data still gets caught via post back. With it, you can warn the user faster that there is an issue.

There's a pessimistic theme I meant to mention - never trust the user. Either they're going to make a mistake, or they're out to break your app.

Upvotes: 8

Related Questions