My problem is that it work to set a setCustomValidity on an Lighning:Input element like described here: Solved
The problem is that it is not possible to reset this value onces it is set. Even if I get the correct values the error message do not dissapear if the value was once set to a wrong one.
here is my js code:
var lines = component.get('v.lines');
var inputField = event.getSource();
var inputvalue = event.getSource().get("v.value");
if (inputvalue < lines[0].kalabis__DeliveryDate__c) {
console.log('its to small');
inputField.setCustomValidity('wrong');
} else {
console.log('its ok');
inputField.setCustomValidity('');
component.set('v.isLoaded', false);
component.set('v.isLoaded', true);
}
inputField.reportValidity();
No idea if there is a possibilitty to reset this value but it seems to me very weird.
Best Answer
Workaround
Hi @utm, I've found workaround. If you wrap your component inside IF statement and switch on and off, it will force component to re-render.
With this hack it will work just fine.
Example
Now you need to call
component.set('v.isLoaded', false);
and thencomponent.set('v.isLoaded', true);
forcinglightning:input
to re-render.Message will disappear.
Hope it helps,
Daniel