Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript validation and PHP validation?

Tags:

javascript

php

I am using jquery validation plugin for validation empty forms. Should I also check this in PHP to be sure on 100%? Or it is ok with javascript validation. Thanks

like image 947
ideea Avatar asked Dec 29 '22 08:12

ideea


2 Answers

You should always do your validation on the server.

What happens if a user submits the form in some way not using Javascript? Then all of the JS validation is null and void. Never trust Javascript alone. It's a very nice tool to use to make the site look slick, etc, but you can't assume the user will use it, even if you set it up that you aren't letting them submit normally.


When I personally put client and server side validation up, I work them to be the exact same validations. That way, the user typically doesn't see the server validation, but if something goes wrong, the information is still validated a much as necessary.

like image 164
Jeff Rupert Avatar answered Dec 30 '22 22:12

Jeff Rupert


Users can disable javascript wich would bypass all your checking. For this reason you should always check input with php. Validating with javascript is mostly to make use of fancy ajax and jquery visuals. The real validation is always serverside.

like image 45
Iznogood Avatar answered Dec 30 '22 20:12

Iznogood