All the suggestions appear to be valid - except the one using JavaScript.
DO NOT USE CLIENT SIDE VALIDATION AS YOUR ONLY METHOD OF VALIDATION.
You put the server at risk, as well as files and databases when you do not validate on the server-side.
JavaScript can be turned off on a browser - and is NOT used for text-based browsers like Lynx.
By all means, use JavaScript to validate IF you are also validating on the server-side from within the script.
Originally posted as a Categorized Answer.