I have a picklist with certain values that make another field required. I am trying to get the field required value to rerender when the picklist value changes, but no luck so far. I have tried adding a blank action to the actionSupport tag to no avail.

Page Snippet:

<apex:inputField value="{!someAccount.someField}">
    <apex:actionSupport event="onchange" reRender="otherFieldRequired" />
<apex:pageBlockSectionItem id="otherFieldRequired">
    <apex:outputLabel value="Other Field Required?" />
    <apex:outputText value="{!IF(isOtherFieldRequired, 'Yes', 'No')}" />

Controller Snippet:

public static Set<String> requiredPicklistValues = new Set<String> { 'A', 'B', 'C' };
public Account someAccount {get; set;}
public Boolean isOtherFieldRequired { get { return requiredPicklistValues.contains(someAccount.someField); } }
  • Did you try enclosing the pageblock inside of an outputPanel with the id as otherFieldRequired? I know it is usually a pain in the keister about that. Aug 5, 2013 at 21:25

1 Answer 1


Just need to create a property in the controller to let the page know whether or not the field is required. You set that property int he action of the actionSupport, and then rerender.

VF Page

<apex:inputField value="{!someAccount.someField}">
     <apex:actionSupport event="onchange" action="{!checkRequired}" reRender="otherFieldRequired" />
<apex:outputPanel id="otherFieldRequired">
     <apex:inputField id="dependentField" required="{!isRequired}"/>


public boolean isRequired  {get;set;}{isRequired=false;}

public PageReference checkRequired(){
     //Your logic to check if the appropriate pick list values have been set for the input field
     if(//your check){
          isRequired = true;
  • Adrian, did you try this? Aug 26, 2013 at 1:04
  • I have similar problem. I can't make second field not required if I set the first value to value different from the list.
    – Patlatus
    Sep 22, 2014 at 9:08
  • 1
    It seems it is impossible to make field "Not required" dynamically once it was marked as "required". Dumb visualforce
    – Patlatus
    Sep 22, 2014 at 9:18
  • @Patlatus Yep it seems once required, always required. Unfortunate.
    – Adrian Larson
    Oct 30, 2015 at 18:11
  • Actually I have been playing with javascript, trying to mark field as required or unmark. Also I am thinking now, if Chris example might work in case if we surround first <apex:inputField> with <apex:actionRegion> tag
    – Patlatus
    Nov 1, 2015 at 7:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .