form validation for login and register pages