Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is javascript validation enough to keep my forms secure? [closed]

I am building a website and I have a questions with forms on login/registration page. I have a few standard javascript validations on the login page. My questions is should I just disable the login button if javascript is disabled or should I keep PHP validations on the server side code?

Which is a better approach in terms of security? I am planning to keep login/registration button disabled and only enable it by javascript. That way I can avoid writing PHP side validation of the same JavaScript that is already there. Is it a secure way of doing it?

Thanks

like image 566
Gaurav Mehta Avatar asked Dec 06 '22 06:12

Gaurav Mehta


1 Answers

Overall, use PHP. Javascript can be easily fooled and/or turned off entirely. At that point your server gets supplied with whatever Mr Malicious End User wants you to have, and you won't be stopping them.

Use PHP for validation, and if you want it to look fancy, put javascript on top. But ALWAYS server-side validate.

like image 199
castis Avatar answered Dec 08 '22 19:12

castis