What is the effective way to validate a form? | Sololearn: Learn to code for FREE!


What is the effective way to validate a form?

Php form comprises of name, username, email and password. Client validation or Server validation or both? Why? And how?

11/7/2018 12:59:21 AM

Ebrus Johnson

4 Answers

New Answer


Hi As always it depends :) From your application target users, scale, design and ux... But general answer should be: both validations. Client side for 1st line of validation, it is fast and user friendly when he can get the message what is wrong immediately, on each field, not only after submiting whole form. Server side: for security. This is the only real place where you can really block wrong data. Please be aware that people can omit your client validations (or even do not use your client at all). Also some data (for example if username is unique) can be checked only on server side.


Form validation on the server side is more effective because the user cannot manipulate the scripts on this side. But for stronger security, it is highly recommended to have form validation on the client side as well.


Client validation is user-friendly but should never be trusted as client-side code is public and you can live edit it to skip validation