I know that php can validate data input before querying to the database

but which is more preferable by the developer or user experience?

validation thru php? or validation thru javascript?

whats your insight about this?

thank you!

5 Years
Discussion Span
Last Post by anthonyjpv

i guess the question is not whether to validate through php (server side) or through javascript(client side).. i think it is more of a question of validating the form before sending to the server or sending the form to be validated at the server..

i guess one of the reason's why a lot of effort has been placed into ajax is because it is, IMHO, better to validate while still at the form prior to sending the data.


Users want nice looking websites and javascript validation does perform some nice visual tricks, however...

webmasters want security because ANY data coming from a users browser via a URL GET or POST even cookie information is suspect and needs to be checked server side before the other script functions get to use it.

To keep both happy then both systems should be used.


what ^he^ said

validation solely at the client is useless, information can be spoofed too easily
validation solely at the server is useless, too many reloads for incomplete forms, large amounts of data transfer for no real purpose
combination of clientside, so the form is completely filled, the data is appropriateley formed;, then at the server to validate the data and complete the submission

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.