Running (custom) validators should also execute setCustomValidity on the element #16353
Comments
The problem with that is that the error shows up to the user, so it is application-specific. Angular can't set it arbitrarily. Maybe we could add a way for the error to be specified by the dev. |
Though the message is not automatically shown to the user, but being stored in the If you set novalidate on the form, then the messages will not be shown, and in combination with AngularJS, that's something you always want to do. Now I have done some further reading on the validation api, and found out several things to be aware of:
So if we add this as a feature, we will need to think about how to do it and how it will impact existing behavior. Though I would like to see it in there and would love to experiment with this. I would love to hear other opinions, to why we should or should not do this, and if there are better ways etc... |
In general, what benefit does calling setCustomValidity give you if you decide not to show the message? AngularJS already provides the Regarding localization - the message shown is what you pass to setCustomValidity, so you have to localize it yourself. Only the default constraints are localized.
Not really sure what you mean by this.
The browser decides how to display the constraint validation errors. There's nothing AngularJS can do here. Personally, I see little need for this - except if you want to show the browser's built-in error messages, which people rarely want. |
@dietergeerts, it is shown to the user if you don't use
I am not sure what you mean either 😕. The message (if we choose to implement this) would be tied to the validator.
I would stick to what browsers do here. (I haven't looked it up, but whatever they do, we should do.)
@Narretz, the main reason for using In general, I think this is a nice-to-have (since it allows better integration with native browser APIs), but wouldn't go to great extends to implement it if it turns out to be tricky. |
I mean that the defaults can't be set. Required for example is being automatically checked by the browser, but it's message can't be set, so setCustomValidity must be used to set it. It's true that when you don't use novalidate, they are being shown, so an option is needed to use it or not. Great idea to try to have this as a 3rd-party module. I will give that a go and report here how it goes, though it could take me a while as I don't have much spare time for the moment. |
I'm submitting a ...
Current behavior:
Right now, when validators run, they only set the AngularJS validity, and not the HTML validtity. Because of this, we can't use the :invalid pseudo selector, which is used by Bootstrap 4 to display the validation styling.
Expected / new behavior:
Running validators should also set the the HTML validity in order to use :invalid pseudo selector.
AngularJS version: 1.5.11 (I checked source code of the latest version on master too)
Browser: [al]
Anything else:
I don't know if PR can still be made on this. If so, I could check it out to create one.
The text was updated successfully, but these errors were encountered: