PHP validation better then java script?

Hi,
I use PHP validation for my sites it is better then java script validation ?

it’s not better, since you shouldn’t really compare between them. JavaScript validation should be for user convenience to reduce user waiting times. However, you should never relay purely on JS validation, since it can be disable or modified. So server validation is always required even if you have JS validation.

hi igv

How are you? I would like to thanks for give your comment.

Thanks

no problem, hope you’ll find it useful for you.

Welcome to SitePoint by the way :slight_smile:

Neither is better since they serve two entirely different purposes.

PHP validation is your validation. It ensures that the information you receive is what you expect to receive and rejects anything that isn’t correct. Without it there is nothing to stop you from receiving JUNK.

JavaScript validation is for your visitor. It provides those with JavaScript enabled with more immediate feedback as they are filling out the form. Without it your visitor has to wait until after they submit the form to find out if they entered it correctly.

Use both.
Javascript to spot errors before the user submits (avoids having to re-enter data), and PHP to catch those with JS disabled or trying something unusual or sneaky.

Two barriers are better than one.