+ Start a Discussion
Alekya AtluriAlekya Atluri 

how to check condition and disable button

How to check the condition and disable a button in lightning.
Suppose for example I have a object Account and custom field number__c if account.lnumber__c <=0 then edit and new buttons should be disabled.

Thanks in Advance
Rahul.MishraRahul.Mishra
Hi Alekya,

Do you mean, how to disable button in lightning components based on some condition ?, if so here is the code, in aura:if you can check the condition and make the button disabled:
 
<aura:if isTrue="{!v.isDisabled}">
    <button aura:id="toggleButton" disabled/>
    <aura:set attribute="else">
        <button aura:id="toggleButton"/>
    </aura:set>
</aura:if>

Mark solved if it does help you