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
vijayskvijaysk 

How to enable/disable attribute of Apex:commandButton using javascript in visualforce without controller

I have an apex:inputfield and Apex:commandbutton and i need to make the attribute"Disabled" of Apex:Commandbutton to true/false on click of apex:inputfield using javascript without using controller.Is it possible to do it ?If so please provide the sample code.
ManojSankaranManojSankaran
Hi Kotes,


Use this javascript method in onclick. This will disable the command button.


function disableButton(){
     document.getElementById("buttonId").className ="btnDisabled";
}


Thanks
Manoj S
vijayskvijaysk
Hi Manoj,

Thanks for the reply.But Expected behavior is different like i have below:-

<apex:inputField value="{!ABC}" />

<apex:commandButton id="mybtnid" value="NEXT" disabled="true"/>  // initially to true

Now, i need to make "disabled" of button "Next" to false when i click on inputfield text using javascript.Is it possible?

Note: i have taken the above function but i dont have class for "commandbutton" inorder to get the name of button.