---
schema_version: "1"
id: 9f7a094b807ee1fc5d3fbe7193d0b4f37c242eb942abe35bb9b0e39f3f594abb
title: Validation Error (Deprecated)
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/validationError/ui-validation-error.md
canonical_url: https://developer.salesforce.com/docs/platform/lightning-component-reference/guide/ui-validation-error.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: c308dc8484ac1c5204f11def521e8f66d86bd3923cd7b800a9a60d6448522aa2
products:
  - Lightning Component Reference
---
# Validation Error (Deprecated)

**`ui:validationError`**

Indicates that the component has validation error(s).

::::::tabset{tabs='[ "Develop", "Specifications"]'}

:::::tab

This event is fired when a validation error occurs on an input field. To set a handler for the `ui:validationError` event, use the `onError` 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}"
    onError="{!c.handleError}"
  />
  <ui:button label="Validate" press="{!c.handleValidate}" />
</aura:component>
```

Here's the client-side controller that handles the input validation and handling of the validation error.

```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);
    }
  },

  handleError: function (cmp, evt, helper) {
    alert("An error was found in your input.");
  },
});
```

If you're using this event with a component other than those that extend `ui:input`, register the event first.

```xml
<aura:registerEvent
  name="onError"
  type="ui:validationError"
  description="The event fired when validation errors occur."
/>
```

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)

:::::

::::::
