Refactor for html5 form validations