You need to sign in to do that
Don't have an account?
Santosh Reddy9989
event.getSource() was not working
Here's my component code:
<aura:component implements="force:lightningQuickAction,force:hasRecordId" access="global" >
<ui:inputText aura:id="PlanName" label="Plan Name" required="true" change="{!c.onChange}"/>
<ui:inputnumber aura:id="Amount" label="Amount" required="true" change="{!c.onChange}" />
<lightning:button label="Add New Card" aura:id="newcard" onclick="{!c.chargefun}" />
</aura:component >
component.js code :
({
onChange : function(component, event, helper)
{
var selectCmp = event.getSource();
selectCmp.set("v.errors",null);
},
chargefun : function(component,event,helper)
{
var PlanName = component.find("PlanName").get("v.value");
var amt = component.find("Amount");
var amount = amt.get("v.value");
if($A.util.isEmpty(amount) || $A.util.isEmpty(PlanName ))
{
if ($A.util.isEmpty(amount))
{
amt.set("v.errors", [{message:"Please Enter Value"}]);
}
if ($A.util.isEmpty(PlanName))
{
component.find("PlanName").set("v.errors", [{message:"Please Enter Value..."}]);
}
},
})
In above code, event.getSource() was not working for <ui:inputnumber>. So iam not able to remove error message.
<aura:component implements="force:lightningQuickAction,force:hasRecordId" access="global" >
<ui:inputText aura:id="PlanName" label="Plan Name" required="true" change="{!c.onChange}"/>
<ui:inputnumber aura:id="Amount" label="Amount" required="true" change="{!c.onChange}" />
<lightning:button label="Add New Card" aura:id="newcard" onclick="{!c.chargefun}" />
</aura:component >
component.js code :
({
onChange : function(component, event, helper)
{
var selectCmp = event.getSource();
selectCmp.set("v.errors",null);
},
chargefun : function(component,event,helper)
{
var PlanName = component.find("PlanName").get("v.value");
var amt = component.find("Amount");
var amount = amt.get("v.value");
if($A.util.isEmpty(amount) || $A.util.isEmpty(PlanName ))
{
if ($A.util.isEmpty(amount))
{
amt.set("v.errors", [{message:"Please Enter Value"}]);
}
if ($A.util.isEmpty(PlanName))
{
component.find("PlanName").set("v.errors", [{message:"Please Enter Value..."}]);
}
},
})
In above code, event.getSource() was not working for <ui:inputnumber>. So iam not able to remove error message.
There is no problem with the event. If I change the value of input field then change event firing.
Event. getSource () is working for <ui:inputText>. But it was not working for a <ui:inputnumber>.
Thanks,
Santosh Reddy