adding js form validation

some code smells in there