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
Yugal MahajanYugal Mahajan 

How to disable command button when the input field value changes?

Prateek BhattPrateek Bhatt
Hi Yugal,

Please use below code to disable comand butotn
<!--  Page: -->
<apex:page controller="exampleCon">
    <apex:form >
        <apex:outputpanel id="form">
            <apex:inputText value="{!testValue}">
                <apex:actionSupport event="onblur" action="{!disableButton}" rerender="form" status="counterStatus"/>
            </apex:inputText>
            <apex:commandButton action="{!save}" value="Save" id="theButton" rendered="{!(!disableFlag)}"/>
        </apex:outputpanel>
        <apex:actionStatus id="counterStatus" 
                           startText=" (processing...)" 
                           stopText=" (done)"/>
    </apex:form>
</apex:page>

/***  Controller: ***/
public class exampleCon {
    public boolean disableFlag {get; set;}
    public string testValue {get; set;}
    
    public PageReference disableButton() {
            disableFlag = true;
            return null;
    }
    public PageReference save() {
            return null;
    }
}