moved form validation logic to js