You need to sign in to do that
Don't have an account?
validate child component from parent componet
We have created a lightning component. Inisde the component we are refering another component. we would like to validate the data inside child component on a button click from parent component.
Can anyone give some sample code or suggestion?
Thanks and Regards
And here is controller code
thanks in advance
Can anyone give some sample code or suggestion?
Thanks and Regards
Here we call child component <div class="slds-modal__content slds-p-around--medium wide400"> <!--Transaction Editor Component Here --> <!--<c:TransactionViewer thistrans="{!v.thistrans}" currencies="{!v.currencies}" tdetails="{!v.thisdetails}" /> --> {!v.body} </div> below is component code is long so I paset only 2 field code <div class="slds-form-element slds-size--1-of-3"> <!--<label class="slds-form-element__label" for="descrField">Description</label>--> <!--<force:inputField aura:id="descrField" class="slds-textarea" value="{!v.thistrans.Description__c}"/> --> <ui:inputText aura:id="descrField" class="slds-input" required="true" label="Description" value="{!v.thistrans.Description__c}"/> </div> <div class="slds-form-element slds-size--1-of-3"> <c:LookupSObject label="Deal/Tranche" pluralLabel="Deal/Tranches" sObjectAPIName="Tranche__c" instanceId="tnxTr" iconName="standard:process" listIconClass="slds-icon-standard-account" selectedId="{!v.thistrans.Tranche__c}" selectedName="{!v.thistrans.TName}" /> </div>
And here is controller code
okTranerror: function(component){ var tratitle = component.find("trannameField").get("v.value"); var haserrors = false; if(!tratitle){ effnamefld.set("v.errors", [{message:"Provide Name First!"}]); haserrors = true; }please help i m try a lot but not success
thanks in advance
You can use events to alert the parent component on validation. You can use events for all actions in child component.
eg: onclick, onhover.. etc.
Thanks and Regards,
Ganesh Babu.
Thanks for reply. I am done the validation without the event actions. now I am not able to show error on the field that will be indicate that the value is null. I am using events on that to show the error but not success.
pls help
below is code for component, client side controller, and helper to show the error where is problem i m not find
thanks