Separating JS for form validation