You use Javascript to perform any validation you trust the client themselves to do. Things such as, checking that they've selected the right number of boxes, checking they've entered an email address that is in the right format (has an @ sign somewhere in it, etc) and so forth.
You use PHP to perform all of that checking AGAIN, and additionally perform things like password validation (comparing it with the database) and other critical input validations that require accessing 'secret' information.
Why? Javascript is VISIBLE TO THE USER. Hence if you used javascript to compare a users given password with his real password, all he has to do is View Source, and he gets the real password anyway. Not smart.
However, we DONT just use PHP and forget about javascript. Why? Because there is a lot of basic validation which can be performed by the client's machine. The main advantage of this being that server traffic is reduced by not needing to revalidate the form continuously and transfer it across.