modify JS to validate before submitting form