You need to sign in to do that
Don't have an account?
Anindya Halder 17
reportValidity() does not clears any displayed error if the input is valid
I am trying to display custom error message in lightning:input field using setCustomValidity() and reportValidity().
Exactly as given in the documentation here :- https://developer.salesforce.com/docs/component-library/bundle/lightning:input/documentation
It displays the right error message when the input is invalid . But it does not remove that error essage when a valid data is entered.
I have even used checkValidity() to confirm that its actually valid.
I have verified this in Chrome and Firefox
In the documentation it clearly says reportValidity() clears displayed wrrors when the input is valid but its not working that way.
Is there any way around this ?
P.S we can not se anything validity object because that is read-only now.
Exactly as given in the documentation here :- https://developer.salesforce.com/docs/component-library/bundle/lightning:input/documentation
({ validateRenewaldate : function(component, event) { var inputCmp = component.find("inputCmp"); var value = inputCmp.get("v.value"); var calcutedValue = <some calculation here>; // is input valid text? if (value > calcutedValue) { inputCmp.setCustomValidity("”); } else { inputCmp.setCustomValidity(""); } inputCmp.reportValidity(); })
It displays the right error message when the input is invalid . But it does not remove that error essage when a valid data is entered.
I have even used checkValidity() to confirm that its actually valid.
I have verified this in Chrome and Firefox
In the documentation it clearly says reportValidity() clears displayed wrrors when the input is valid but its not working that way.
Is there any way around this ?
P.S we can not se anything validity object because that is read-only now.
I'm able to then clear this custom validation error message using:
Here is the lightning:input that is validated: