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
si risi ri 

Able to perform Action even after Onclick button is disabled.

I am using styleClass to disable the button. In UI it is showing as disabled. But when I click on the button, I am able to perform an action. Please suggest me a solution.

  <apex:commandButton id="canceldone" value="Cancel" onclick="OpenModel();return false;" styleClass="searchClass ordervalue btn btn-primary disabled {!IF( Industry == 'Enterprise','','sectionHeader')}" rerender="" ></apex:commandButton>
 
Best Answer chosen by si ri
Maharajan CMaharajan C
Hi,

instead of adding the style class we have disabled property  in CommandButton tag try that one.
 
<apex:commandButton value="Cancel" onclick="OpenModel();return false;"  disabled="{!IF(Industry == 'Enterprise',true,false)}"/>

Thanks,
Maharajan.C

All Answers

Maharajan CMaharajan C
Hi,

instead of adding the style class we have disabled property  in CommandButton tag try that one.
 
<apex:commandButton value="Cancel" onclick="OpenModel();return false;"  disabled="{!IF(Industry == 'Enterprise',true,false)}"/>

Thanks,
Maharajan.C
This was selected as the best answer
Malika Pathak 9Malika Pathak 9
Hii si ri,

If-else doesn't directly work like that, you should make use of the ternary operator and return a boolean value like
 
<Button disabled={(this.state.checkedIds.length == 0? true: false)}>
Delete Selected
</Button>



if you find this helpful mark it as the best answer.
thanks 
Malika Pathak