Javascript Class for form validation