I have written a code for validating the email address. when i click on validation email button it is showing the error like below:

This page has an error. You might just need to refresh it. Unable to find action 'ValidateEmail' on the controller of c:EmailValidation Failing descriptor: {c:EmailValidation}


<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
    <div class="slds-m-around--xx-large">
        <div class="slds-form--stacked">
            <div class="slds-form-element">  
                <div class="slds-form-element__control">
                    <ui:inputText aura:id="txtEmail" label="Email"  placeholder="Email-Address" class="slds-input"/>
            <lightning:button variant="success" label="Validate Email" title="Validate Email" onclick="{!c.ValidateEmail}"/>                       


    ValidateEmail : function(component, event, helper) {  
        var emailField = component.find("txtEmail");
        var emailFieldValue = emailField.get("v.value");
        var regExpEmailformat = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;  
                emailField.set("v.errors", [{message: null}]);
                $A.util.removeClass(emailField, 'slds-has-error');                
                $A.util.addClass(emailField, 'slds-has-error');
                emailField.set("v.errors", [{message: "Please Enter a Valid Email Address"}]);               

1 Answer 1


I copy-pasted your code verbatim into a Lightning App, and it works correctly. If I had to guess, your component doesn't have the latest version of your code, so try deploying again.

Some notes:

  • ui:* elements are deprecated, you should use lightning:* elements instead.
  • -- BEM style CSS selectors are deprecated (in fact, appear to have been removed), you should be using _ instead.
  • Regular Expression email validation is not recommended. Just use lightning:input type="email" instead.
  • You don't need to use SLDS styles with the new component, they come with SLDS automatically.

<div class="slds-m-around_xx-large">
    <div class="slds-form_stacked">
        <lightning:input aura:id="txtEmail" type="email" label="Email"  placeholder="Email-Address" />
    <lightning:button variant="success" label="Validate Email" title="Validate Email" onclick="{!c.ValidateEmail}"/>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .