validating form before submiting it, styling the input when the form is invalid