Why Frontend validation is not enough in a web app?

If you are working on a web application that requires users to submit a form like data. then you need to take care of both frontend and backend validation.

suppose if you have an input tag like this and no validation in the backend then anyone can remove the required tag from the front end and can spam your database.

<input type = "email" name = "email" required/>

want to know how to manipulate the frontend? follow the steps.

  1. open a web app and inspect the page.
  2. double click over any tag you want to change/manipulate.
  3. change the value of the tag whatever you want.
  4. in the below example, I changed the value of z-20 to z-220.
  5. you can manipulate this(in which you are reading the article) page if you are using a laptop/desktop, simply follow the above steps for this page.

Screenshot from 2021-01-26 17-38-18.png

Screenshot from 2021-01-26 17-38-38.png

similarly, anyone can remove required from the input field and can spam your database. so backend validation is a must.

Should I remove frontend validation and use only backend validation?

No, frontend validation is for user experience. and it is also required. for example- when you click over submit button in forms then in most of the cases backend request is sent and the page is reloaded. if you use frontend validation then the form is not submitted until the values given by users are correct.

so make sure when you are making a web application you need to take care of both the front end and back end.