Should I Handle Form Validation on Front or Backend?

Should I Handle Form Validation on Front or Backend?

I was asked this question in an interview. My answer was both are necessary because my experience uses Node.js to build the backend. It has to make sure that the user sent the right type of data. For the front end, Validation can give some hints if they input the wrong format of data for improving the user experience.

For a better answer, I google this question.

- Client-side form validation from MDN #

Screen Shot 2021-06-22 at 4.47.44 PM.png In brief:

  1. An important feature of good user experience
  2. Client-side validation should not be considered an exhaustive security measure(It mean backend validation is essential)

- Should I handle html form validation on front or backend? [duplicate] from StackOverflow #

Here is the recommend answer created by V33R

Screen Shot 2021-06-22 at 4.58.57 PM.png In brief:

  1. Front-end validation provides a better user experience for users and reduces meaningless times to load on the server.
  2. Backend validation is necessary.