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
Shyam Sundar 84Shyam Sundar 84 


check box and text field must be dependent, after checking the check box only you can fill the text field. Need 3 possible approaches
Khan AnasKhan Anas (Salesforce Developers) 
Hi Shyam,

Greetings to you!

<apex:page id="thepage" standardController="Account" >
    <apex:form >
                <apex:inputField value="{!Account.Cb__c}">
                    <apex:actionSupport event="onchange" rerender="pan"/>
                <apex:outputPanel id="pan">
                    <apex:outputLabel value="Text Field" /> &nbsp;&nbsp;
                    <apex:inputText id="test" disabled="{!IF(Account.Cb__c==false,true,false)}" />

2. Using HTML input checkbox and input text
    <input type="checkbox" id="yourBox" />
    <input type="text" id="yourText" disabled="true" />
    document.getElementById('yourBox').onchange = function() {
        document.getElementById('yourText').disabled = !this.checked;

3. using Vf and Apex:
<apex:page id="thepage" standardController="Account" extensions="testComponent">
<apex:form >
    <apex:inputField value="{!acc.Name}">
        <apex:actionSupport event="onchange" action="{!changeCheckBox}" rerender="pan" />
            <apex:outputPanel id="pan">
            <apex:inputField id="test" value="{!acc.Cb__c}"/>

public with sharing class testComponent {

    public testComponent() {


    public Account acc{get;set;}
    public testComponent(ApexPages.StandardController controller) {
        acc=[select id,Name,Cb__c from account where id='Enter_Account_Id'];
    public pagereference changeCheckBox(){
        return null;


4. Use validation rule
AND(Cb__c = TRUE, ISBLANK(Text_Field_Name__c)

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