0

Iam trying to validate the field here. but iam getting below error

   "Cannot read property 'set' of undefined"

      <aura:component>
      <div class="slds-grid slds-gutters">
        <div class="slds-col">
        <span>   <!-- Description -->
            <div class="slds-form-element">
             <!--   <label class="slds-form-element__label" for="description">Description </label> -->
                <div style="width:200px;">
                    <ui:inputText class="description" aura:id="description" label="Description" value="{!v.myDescription}" required="true"/>
                </div>
            </div> </span> 

    </div>

  Savemethod:function(component, event, helper) {
    var description=component.find("description").get("v.value");
    alert(description)
    if(description==null || description=='undefined' ){
        description.set("v.errors", [{message:"description cannot be blank"}]);

    }
    else {
        description.set("v.errors", null);
    }}

1 Answer 1

2

You read the text string from the object. You need to set the value in the attribute:

component.find("description").set("v.errors", [{message:"description cannot be blank"}]);
0

You must log in to answer this question.

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