I've created a register form validation on frontend and backend and I am checking both at the frontend and backend: whether the name and surname consist of letters only, whether the password contains numbers, uppercase and lowercase letters, whether the email is correctly saved.
The interface informs about errors. My question is, since I check all the conditions on the frontend, should the backend also send error messages to the frontend?
I mean both frontend and backend check data validation, but should the frontend react to backend error messages? It seems unnecessary for the backend to send information that f.e. the password is too short, since the frontend already does it. The backend should only make sure that f.e. the password length is appropriate.
Second question: should I check on the backend side whether the checkbox regarding acceptance of the website regulations has been selected or whether the password and the repeated password are the same?
First of all, if you don't want to make validation on both frontend and backend, better to leave backend validation then.
Frontend validation mostly used to:
if you are doing small pet project it might look as good idea to leave only frontend validation. But as application grows you might face a lot of issues here:
So, it's must have to have backend validation. You might miss some validation on frontend (or skip it if it's not necessary, e.g. for admin panel). But missing backend validation is dead end for scalable apps.
Should I check on the backend side whether the checkbox regarding acceptance of the website regulations has been selected or whether the password and the repeated password are the same?
Yep, better to ensure your data is correct before saving data to DB.
Edit: Ah, I see, so you have backend validation. In this case, it really depends on your app. Better to show some explanation so user won't be confused. But sometimes it makes sense to just show that some error occured on server and leave it be.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With