Answer the question
In order to leave comments, you need to log in
How safe is it to do form validation via javascript?
Hello! Recently I started to study the creation of sites and there was such a problem: is it safe to use javascript for form validation? After all, js code is in the public domain and everyone can see it. Also, can the user somehow change my js code? Maybe it's still worth doing validation through php?
Answer the question
In order to leave comments, you need to log in
validation must be done both on the client (for responsiveness, and there is nothing to drive invalid data over the network), and on the server (actually for verification).
It is worth a priori to assume that your form is filled out not by a user on the site, but by a Chinese bot that does not launch any browser. And stupidly sending fields filled with whatever he wants to your server.
Accordingly, you can not rely not only on the fact that your scripts will check something there, but even on the seemingly given input restrictions, such as the fact that the result of this select can only be a number. Sooner or later it will turn out to be a SQL injection string, e.g.
is it safe to use javascript for form validation?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question