If you have to pick one, php. Both is good though. Using javascript means that the user gets immediate feedback and doesn't have to wait for a page reload. However javascript can be disabled or bypassed, so even if you use it for form validation you still have to do another round of validation on the server with php.