---
schema_version: "1"
id: ff4724ae0eaee84aef9399588a9d79241988fcf1256c8faf5aa430e63f2d594c
title: Clear Errors
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/lightning-base-components/lightning-design-system/guides/aura/components/ui/clearErrors/ui-clear-errors.md
canonical_url: https://developer.salesforce.com/docs/platform/lightning-component-reference/guide/ui-clear-errors.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 42ab5cede1cd12df1cacf4b1bb64fc8c6ec2ac5bc990c78018381026ab37d5c2
products:
  - Lightning Component Reference
---
# Clear Errors

**`ui:clearErrors`**

Indicates that validation errors are cleared.

**For Use In**

Lightning Experience, Experience Builder Sites, Salesforce Mobile App

::::::tabset{tabs='["Develop", "Specifications"]'}

:::::tab

This event is fired when validation errors on an input field are cleared. To set a handler for the `ui:clearErrors` event, use the `onClearErrors` attribute on a component that extends `ui:input`, such as `ui:inputText` and `ui:inputNumber`.

The following `ui:inputNumber` component displays an error message when the number entered is less than 10. It displays an alert when the error message is cleared.

```xml
<aura:component>
  <aura:attribute name="myNumber" type="integer" default="10" />
  <ui:inputNumber
    aura:id="number"
    label="Enter a number: "
    value="{!v.myNumber}"
    onClearErrors="{!c.handleClearErrors}"
  />
  <ui:button label="Validate" press="{!c.handleValidate}" />
</aura:component>
```

Here's the client-side controller that handles the input validation and clearing of the error message.

```javascript
({
  handleValidate: function (cmp, evt, helper) {
    var num = cmp.find("number");
    var val = num.get("v.value");
    if (val < 10) {
      num.set("v.errors", [{ message: "Enter a number more than 10" }]);
    } else {
      num.set("v.errors", null);
    }
  },

  handleClearErrors: function (cmp, evt, helper) {
    alert("Error has been cleared");
  },
});
```

If you're using this event with a component other than those that extend `ui:input`, register the event first.

```xml
<aura:registerEvent
  name="onClearErrors"
  type="ui:clearErrors"
  description="The event fired when validation errors are cleared."
/>
```

For more information, see the [Lightning Aura Components Developer Guide](https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/js_validate_fields.htm).


:::::

:::::tab

![No specifications to show](https://developer.salesforce.com/media/no-specs.png)


:::::

::::::
