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
DritterDritter 

VF Page and Required Field Highlight

I have a block with a VF page, and I want the red vertical bar to appear next to a field highlighting it is required. I've found a few suggestions online, but they don't seem to work. Any ideas? 
 
<apex:pageBlockSection title="Account Information" columns="2">
                
                <div class="reuqiredInput">
                    <div class="requiredBlock"></div>
                    <apex:inputText value="{!firstName}" label="First Name" required="true" />
                </div>
                
                <apex:inputField value="{!accountObject.PersonTitle}"/>
                <apex:inputText value="{!lastName}" label="Last Name *"/>
                <apex:inputField value="{!accountObject.Lead_Source__c}" label="Lead Source *"/>
                <apex:inputField value="{!accountObject.Hot_Flag__c}" label="Hot Lead"/>
                
            </apex:pageBlockSection>

 
Best Answer chosen by Dritter
William TranWilliam Tran
Okay, change 
 
CHANGE THIS:

                <div class="requiredInput">
                    <div class="requiredBlock"></div>
                    <apex:inputText value="{!firstName}" label="First Name *" required="true" />
                </div>
       
  TO THIS:
          
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="First Name *" for="thefirstName"/>
                    <apex:outputPanel styleClass="requiredInput">
                        <apex:outputPanel styleClass="requiredBlock" />
                        <apex:inputText value="{!firstName}" id="thefirstName" required="true"/>
                    </apex:outputPanel>
                </apex:pageBlockSectionItem>


As a common practice, if your question is answered, please choose 1 best answer.
But you can give every answer a thumb up if that answer is helpful to you.

Thanks
 

All Answers

William TranWilliam Tran
Your spelling is wrong:

<div class="reuqiredInput">

Should be requiredInput

Can you post the whole page if you are still having issues.

As a common practice, if your question is answered, please choose 1 best answer.
But you can give every answer a thumb up if that answer is helpful to you.

Thanks
DritterDritter

Thanks William, 
 

Yeah, I noticed that typo shortly after I posted. I fixed it, but it still doesn't show up with the red vertical bar. Here's the whole page. 
 

<apex:page controller="clsAccountEntry">
    <apex:form >
        <apex:pageBlock title="Lead Edit" mode="edit">
            <apex:pageBlockButtons >
                <apex:commandButton action="{!saveDetails}" value="Save"/>
                <apex:commandButton action="{!Cancel}" value="Cancel"/>
            </apex:pageBlockButtons>
            <apex:pageBlockSection title="Account Information" columns="2">
                
                <div class="requiredInput">
                    <div class="requiredBlock"></div>
                    <apex:inputText value="{!firstName}" label="First Name *" />
                </div>
                
                <apex:inputField value="{!accountObject.PersonTitle}"/>
                <apex:inputText value="{!lastName}" label="Last Name *"/>
                <apex:inputField value="{!accountObject.Lead_Source__c}" label="Lead Source *"/>
                <apex:inputField value="{!accountObject.Hot_Flag__c}" label="Hot Lead"/>
                
            </apex:pageBlockSection>
            
            <apex:pageBlockSection title="Contact Information" columns="2">
            
                <apex:inputField value="{!accountObject.PersonEmail}"/>
                <apex:inputField value="{!accountObject.Phone}" label="Phone"/>
                <apex:inputField value="{!accountObject.Email_2__c}" label="Additional Email"/>
                <apex:inputField value="{!accountObject.Phone_2__c}" label="Additional Phone"/>
                
            </apex:pageBlockSection>

            <apex:pageBlockSection title="Communication Preferences" columns="2">

                <apex:inputField value="{!accountObject.Do_Not_Mail_Flag__c}"/>
                <apex:inputField value="{!accountObject.Do_Not_Call2__c}"/>
                <apex:inputField value="{!accountObject.Email_Opt_Out2__c}"/>
                <apex:inputField value="{!accountObject.Nat_Do_Not_Call_Flag__c}"/>
                
            </apex:pageBlockSection>

            <apex:pageBlockSection title="Interests" columns="2">

                <apex:inputField value="{!interestObject.Expected_Prep_Start_Date__c}"/>
                <apex:inputField value="{!interestObject.Program_Of_Interest__c}"/>
                <apex:inputField value="{!interestObject.Sensitivity_to_Pricing__c}"/>
                <apex:inputField value="{!interestObject.Expected_Test_Date__c}"/>
                
            </apex:pageBlockSection>

            <apex:pageBlockSection title="School" columns="2">

                <apex:inputField value="{!schoolObject.School_Name__c}"/>
                <apex:inputField value="{!schoolObject.Graduation_Year__c}"/>
                <apex:inputField value="{!schoolObject.No_School__c}"/>
       
            </apex:pageBlockSection>

            <apex:pageBlockSection title="Create Relationship" columns="2">

                <apex:inputField value="{!relationObject.Account__c}" label="Find Existing Account"/>
                <apex:inputField value="{!relationObject.Relation_Type__c}"/>
                <apex:inputField value="{!relationObject.Parent_First_Name__c}"/>
                <apex:inputField value="{!relationObject.Parent_Last_Name__c}"/>
                <apex:inputField value="{!relationObject.Email_1__c}" label="Email"/>
                <apex:inputField value="{!relationObject.Phone_1__c}" label="Phone"/>
                
            </apex:pageBlockSection>

            <apex:pageBlockSection title="Address Information" columns="2">
            
                <apex:inputField value="{!accountObject.BillingStreet}" label="Billing Street"/>
                <apex:inputField value="{!accountObject.shippingStreet}" label="Shipping Street"/>
                <apex:inputField value="{!accountObject.BillingCity}" label="Billing City"/>
                <apex:inputField value="{!accountObject.shippingCity}" label="Shipping City"/>
                <apex:inputField value="{!accountObject.BillingState}" label="Billing State"/>
                <apex:inputField value="{!accountObject.shippingState}" label="Shipping State"/>
                <apex:inputField value="{!accountObject.BillingPostalCode}" label="Billing Zip Code"/>
                <apex:inputField value="{!accountObject.shippingPostalCode}" label="Shipping Zip Code"/>
                <apex:inputField value="{!accountObject.BillingCountry}" label="Billing Country"/>
                <apex:inputField value="{!accountObject.shippingCountry}" label="Shipping Country"/>
                
                <apex:pageBlockSectionItem />
                <apex:pageBlockSectionItem />
                <apex:pageBlockSectionItem />
                <apex:pageBlockSectionItem />
                
                <apex:inputField value="{!accountObject.Other_Address_Line_1__c}" label="Other Street"/>
                <apex:inputField value="{!accountObject.School_Address_Line_1__c}" label="School Street"/>
                <apex:inputField value="{!accountObject.Other_City__c}" label="Other City"/>
                <apex:inputField value="{!accountObject.School_City__c}" label="School City"/>
                <apex:inputField value="{!accountObject.Other_State__c}" label="Other State"/>
                <apex:inputField value="{!accountObject.School_State__c}" label="School State"/>
                <apex:inputField value="{!accountObject.Other_Postal_Code__c}" label="Other Zip Code"/>
                <apex:inputField value="{!accountObject.School_Postal_Code__c}" label="School Zip Code"/>
                <apex:inputField value="{!accountObject.Other_Country__c}" label="Other Country"/>
                <apex:inputField value="{!accountObject.School_Country__c}" label="School Country"/>
                
            </apex:pageBlockSection>
            
           <apex:pageBlockSection title="Additional Information" columns="2">

               <apex:inputField value="{!AccountObject.F1_Flag__c}" label="Fl"/>
               <apex:inputField value="{!AccountObject.Country_of_Citzenship__c}" label="Country of Citzenship"></apex:inputField>
               <apex:inputField value="{!AccountObject.ABA_Number__c}" label="ABA Number"/>
               <apex:inputField value="{!AccountObject.AMA_Number__c}" label="AMA Number"/>
      
            </apex:pageBlockSection>
            

            <apex:pageBlockSection title="Description Information" columns="1">
                
                <apex:inputField value="{!accountObject.Description}" style="width: 70%; height: 100px;"/>
                
            </apex:pageBlockSection>

        </apex:pageBlock>
    </apex:form>
</apex:page>
William TranWilliam Tran
Okay, change 
 
CHANGE THIS:

                <div class="requiredInput">
                    <div class="requiredBlock"></div>
                    <apex:inputText value="{!firstName}" label="First Name *" required="true" />
                </div>
       
  TO THIS:
          
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="First Name *" for="thefirstName"/>
                    <apex:outputPanel styleClass="requiredInput">
                        <apex:outputPanel styleClass="requiredBlock" />
                        <apex:inputText value="{!firstName}" id="thefirstName" required="true"/>
                    </apex:outputPanel>
                </apex:pageBlockSectionItem>


As a common practice, if your question is answered, please choose 1 best answer.
But you can give every answer a thumb up if that answer is helpful to you.

Thanks
 
This was selected as the best answer