validate icon indicating copy to clipboard operation
validate copied to clipboard

Fixed hasError to also return custom error messages

Open bofrede opened this issue 8 years ago • 3 comments
trafficstars

Error messages set by setCustomValidity was ignored.

bofrede avatar Sep 26 '17 09:09 bofrede

I'm not sure this will work in it's current form, since any other message other than the generic one will return first and the custom error will never surface.

cferdinandi avatar Sep 29 '17 11:09 cferdinandi

@cferdinandi Thanks for your research and articles on HTML5 forms. It's good to finally being able to use HTML5 form validation.

I agree, that the generic errors are suppressing the custom error message, but without this fix, custom error messages are always ignored. So, while this solution may not be perfect, it's still a tangible improvement.

The fields I used custom errors on have been required fields, so I didn't miss an additional error message.

bofrede avatar Sep 29 '17 12:09 bofrede

I don't think this is a problem. I use custom errors e.g. to validate the availability of a username or email address. In this case it makes perfect sense that first of all the visitor has to enter something, secondly it has to be of valid format and only then I will tell him about availability.

I just integrated support for setCustomValidity in https://github.com/michapietsch/validate/commit/94022b047c1a66bbcbc81eeedbaa31f790ab4f92. Maybe you find it useful.

michapietsch avatar Apr 06 '18 15:04 michapietsch