How to disable button in Salesforce Visualforce Page?

How to disable button in Salesforce Visualforce Page?

disabled attribute in apex:commandButton can be usedto disable button in Salesforce Visualforce Page.

Visualforce Page:

 <apex:page controller="Sample" sidebar="false">
    <apex:pagemessages />
    <apex:form >
        <apex:commandButton value="Disable" disabled="{!disabl}" action="{!dis}"/>
    </apex:form>
</apex:page>

Apex Controller:

public class Sample
{
    public Boolean disabl {get;set;}
   
    public void dis()
    {
        disabl = true;
    }
}

Output:

After clicking the button

Leave a Reply