You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.
So, I'm having a MDCTextfield that is initialized automatically.
I want to validate it by myself and this can't be done with any pattern or max-/minlength attribute.
As far as I understood the documentation all that's to do is calling setCustomValidity with any string as a parameter, but after doing so the field isn't marked as invalid. getting the validation properties of the HTMLInputElement also doesn't show anything.
Am I missing something out or is something catching and reverting the invalid status?
Just giving the .mdc-textfield the class mdc-textfield--invalid is also not working because the field may get and lose it's focus afterwards again (i tested it without any focus changes, too).
The text was updated successfully, but these errors were encountered:
I would also like this feature to be implemented. Looking at the foundation class the validity is being set on blur. A better implementation would be to have a property 'setValidity' that you can set yourself and another variable 'useNativeValidityChecking' that will be true by default and when setValidity will be called it will become false. So this will not break current implementations of the textfield.
I will do a commit in my fork. And I would like to hear the opinion of a member of the project.
The valid variable is just a setter. The only way to implement a getter in the foundation would require the adapter to have a function hasClass and check for this.adapter_.hasClass(INVALID); or an additional variable that keeps track of the validity.
So, I'm having a MDCTextfield that is initialized automatically.
I want to validate it by myself and this can't be done with any pattern or max-/minlength attribute.
As far as I understood the documentation all that's to do is calling
setCustomValidity
with any string as a parameter, but after doing so the field isn't marked as invalid. getting the validation properties of the HTMLInputElement also doesn't show anything.Am I missing something out or is something catching and reverting the invalid status?
Just giving the
.mdc-textfield
the classmdc-textfield--invalid
is also not working because the field may get and lose it's focus afterwards again (i tested it without any focus changes, too).The text was updated successfully, but these errors were encountered: