Generic form validations using JavaScript