Search code examples
javascriptperformancevalidationclient-side-validationserver-side-validation

Is client-side validation unnecessary?


Please check this question before. I frequently heard about

"... don't trust the client ! never trust the client ! never trust the user inputs !"

I agree with client-side validation alone is a very bad idea. But if so , what is the advantages of using client-side validation ? Is it necessary or not? When should I use client-side validation ?

Forget about some bad guys (who try to hack), please think about should every request reach to server side ? I don't think so . Normal users can input wrong datas and these should be mostly end at the client side. I believe that it may improve site's performance.

I tried to Disable developer tools in my site to moderate bad guys. I use both client-side and server-side validations for my sites. I believe client-side validations were also needed. Any suggestions for using client-side validation ?


Solution

  • I personaly use like you both of them.

    Imagine Email Regex:

    Clientside:

    You help the User do know about a mistake, if he forget @ or something like that

    Serverside:

    The best Regex can't help you, to know the Email is availible. You need to send him a Email.

    General

    Use Clientside Validation to help the User to detect Errors, use Serverside Validation, if you need some Data in a specific format.