function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Niraj Singh 28Niraj Singh 28 

change value of messageWhenValueMissing by javascript

Hello All,

I needed to change value of messageWhenValueMissing using javascript.


Thanks & HNY2019
Best Answer chosen by Niraj Singh 28
Raj VakatiRaj Vakati
Try like this
 
<aura:component >
    <aura:attribute name="truthy" default="true" type="boolean"/>
	    <aura:attribute name="mesasge" default="First name is required" type="boolean"/>

    <lightning:button label="Click Me" onclick="{!c.clickMe}" />
     <aura:if isTrue="{!v.truthy}">
    <lightning:input type="text" name="firstName" required="true" aura:id="firstName" label="First Name" value="{!v.firstName}" 
    messageWhenValueMissing="{!v.message}"/>
    </aura:if>     
</aura:component>
 
compCreate:function(com,eve,helper){
   com.set('v.mesasge','Error from JS');
      com.set('v.truthy',true);
}