What is the effective way to validate a form? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

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?

7th Nov 2018, 12:59 AM
Ebrus Johnson
Ebrus Johnson - avatar
2 Answers
+ 6
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.
7th Nov 2018, 8:20 PM
Ja Mi
Ja Mi - avatar
+ 2
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.
8th Nov 2018, 11:49 AM
Carlette Jean A.