Lightning:Input – Hide (Reset) Field Level Error message Enabled by using showHelpMessageIfInvalid()

Have few Lightning:Input and Lightning:Select components in My Component A.
All the fields are having Required attribute as ‘true’.
Once fields are validated, Field level error (help) messages appear at the bottom of the field and will be there until input Field data is changed (is valid). I have used showHelpMessageIfInvalid() to enable this error message on field explicitly from controller.

I would like to Reset(Hide) the error messages on all these fields from Controller.
Is there any way to do this?
Looks like “errors” is not a valid attribute for Lightning:Input / Lightning:Select components. Below attempt failed.

component.find('FieldAuraID').set('v.errors', null);



Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

If you really wanted to hide error messages you could do something like this:


    <lightning:input label="First Name" aura:id="firstName" required="true"/>
    <lightning:button onclick="{!c.hideErrors}">Hide Errors</lightning:button>


hideErrors : function(component, event, helper) {
    var el = component.find("firstName");
    $A.util.removeClass(el, "slds-has-error"); // remove red border
    $A.util.addClass(el, "hide-error-message"); // hide error message


.THIS .hide-error-message > .slds-form-element__help {

.THIS .hide-error-message > .slds-form-element > .slds-form-element__help {
    display: none;

But the internal DOM structure and class names of base components are subject to change so this isn’t a totally robust solution.

Method 2

In my case with hidden form the approach below was more appropriate:

<aura:component >
  <aura:attribute name="isVisible" type="Boolean" default="true" />
  <aura:attribute name="field1" type="String" />
  <aura:attribute name="fieldsValidity" type="Object[]" />

  <aura:if isTrue={!v.isVisible}">
    <lightning:input name="textInput" value="{!v.field1}" 
                     validity="{!v.fieldsValidity.field1}" />

  <lightning:button label="Clear" onclick={!c.clearErrors} />


clearErrors: function(cmp){
   cmp.set('v.fieldsValidity.field1', null);

   cmp.set('v.isVisible', false);
   cmp.set('v.isVisible', true);

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x