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
brijender singh rathore 16brijender singh rathore 16 

Help me with adding render and rerender functionalities on page

My requirement is whenever the checkbox Did you confirm by DOB is true. The required field DOB will display and when the checkbox is false it will not.

Now the issue is when i am making the checkbox true field display but when i make it false it shows the following message and does not disappear from page

Please verify my code and tell me where is the problem. Also please verify that i am following the right way to make the field required. As i want this field only when the checkbox is true. This is the code
<apex:inputcheckbox value="{!chkBx2}" label="Did you confirm by DOB" > <apex:actionSupport event="onchange" rerender="thePanel" action="{!click2}"/> </apex:inputcheckbox> <apex:outputPanel id="thePanel" > <apex:pageBlockSectionItem rendered="{!displayInputputText}"> <apex:outputLabel escape="true" id="Component49" style="width:228px;" value="{!$ObjectType.BGC_Criminal_Search_Record__c.fields.DOB__c.label} "/> <apex:inputField id="Component43" value="{!record.DOB__c}" required="{!IF(chkBx2,true,false)}" /> </apex:pageBlockSectionItem> </apex:outputPanel>
 
public Boolean displayInputputText{get;set;}
  public Boolean chkBx2{get;set;}
      public PageReference click2(){    
    if(chkBx2){
      displayInputputText = true;
    }
    else{
      displayInputputText = false;
    }
    return null;
  }

User-added image
Bear RobinsBear Robins

I didn't face this issue and I think no one i getting this issue You have to confirm it again. 

1st birthday wishes (https://www.go-happybirthday.com/2019/02/happy-1st-birthday-boy-girl.html)

brijender singh rathore 16brijender singh rathore 16
@Bear Robins. If you don't know the answer let others help. Please don't waste your valuable comment.
Dushyant SonwarDushyant Sonwar
You can use actionRegion for this. I have made some changes in your code . It works for me.
 
<apex:actionRegion>
  <apex:inputcheckbox value="{!chkBx2}" label="Did you confirm by DOB" > 
      <apex:actionSupport event="onchange" rerender="thePanel" action="{!click2}" /> 
  </apex:inputcheckbox>
  </apex:actionRegion>
Hope this helps.