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
Chaitra GVChaitra GV 

How to disable a button on visualforce page

I wanted to disable edit button once the status of case is closed. Is it possible to disable a button in visualforce? How can it be achieved?
Best Answer chosen by Chaitra GV
Ajay K DubediAjay K Dubedi
Hi Chaitra,
Use the below line of code in your vf page:

<apex:commandButton value="Submit" disabled="{!hidebutton}"/>  

In your Apex class make a Boolean variable named "hide" that will initially be false inside the constructor.
As per your condition, you can make your button disabled or undisabled by simply turning Boolean variable hide value
to true or false.

In Apex:
public Boolean hidebutton{get;set;}

Also, go through the links below for more information:
http://www.infallibletechie.com/2013/01/how-to-disable-button-in-visualforce.html
http://www.infallibletechie.com/2013/12/how-to-disable-and-enable-button-in.html
I hope this explanation is helpful. Mark it as best answer if it helps so that others also get help from this.

Thanks.
Ajay Dubedi

All Answers

Khan AnasKhan Anas (Salesforce Developers) 
Hi Chaitra,

Greetings to you!

Please refer to the below links which might help you further with the above requirement.

http://blogatsalesforce.blogspot.com/2015/04/enable-disable-buttons-on-standard.html

https://developer.salesforce.com/forums/?id=906F0000000Ag39IAC

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas
Ajay K DubediAjay K Dubedi
Hi Chaitra,
Use the below line of code in your vf page:

<apex:commandButton value="Submit" disabled="{!hidebutton}"/>  

In your Apex class make a Boolean variable named "hide" that will initially be false inside the constructor.
As per your condition, you can make your button disabled or undisabled by simply turning Boolean variable hide value
to true or false.

In Apex:
public Boolean hidebutton{get;set;}

Also, go through the links below for more information:
http://www.infallibletechie.com/2013/01/how-to-disable-button-in-visualforce.html
http://www.infallibletechie.com/2013/12/how-to-disable-and-enable-button-in.html
I hope this explanation is helpful. Mark it as best answer if it helps so that others also get help from this.

Thanks.
Ajay Dubedi
This was selected as the best answer