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
NaveenReddyNaveenReddy 

Required Field's Red Bar not enabling

Hi,

 

  I have a requirement .

 

Whenever a text fied is changed(or entered text) the  other text field should be marked as required.

 

I used the following code but it is not happening.

 

<apex:page controller="sampleOne" >

    <apex:form >
        <apex:pageBlock >
          <apex:pageBlockSection >
                   <apex:inputText  label="name" />
                  <apex:actionSupport event="onchange" action="{!setName}"  rerender="counter" />
                    <apex:inputText required="true" value="{!Name}" label="name2" id="counter"/>
          </apex:pageBlockSection>
          </apex:pageBlock>
    </apex:form>

</apex:page>

 

 

 

public with sharing class sampleOne {

public boolean Name{get ;set ;}

  public void setName()
 {
   this.Name=true;
   System.debug('___________________________setname');
}
public boolean getName()
  {
   return Name;
   }
}

robdobbyrobdobby

The "required" parameter is annoying that it doesn't show the standard SF styling by default.  Try wrapping it with outputPanels with "requiredInput" and "requiredBlock" classes like this:

 

<apex:page controller="RobsTest_Controller" >

  <apex:form >

    <apex:pageBlock >

    <apex:pageBlockSection >

      <apex:outputPanel styleClass="requiredInput" layout="block">

      <apex:outputPanel styleClass="requiredBlock" layout="block"/>

      <apex:inputText required="true" value="{!NameString}" label="name2" id="counter"/>

      </apex:outputPanel>

    </apex:pageBlockSection>

    </apex:pageBlock>

  </apex:form>

</apex:page>

 

 

public with sharing class RobsTest_Controller {

  public String NameString {public get; public set;}

}