Required field mark (Red Vertical Bar) not coming

You can "simulate" the redbar like this:

<apex:pageBlock >
    <apex:pageBlockSection>
        <apex:pageBlockSectionItem>
            <apex:outputPanel>
                <div class="requiredInput">
                    <div class="requiredBlock"></div>
                    <apex:inputText value="{!numberOfRowToRemove}"/>
                </div>
            </apex:outputPanel>
        </apex:pageBlockSectionItem>
    </apex:pageBlockSection>
</apex:pageBlock>

Finally i have find out the solution.

            <apex:pageBlockSectionItem >
                <apex:outputLabel value="Name on Card" />
                <apex:outputPanel >
                    <div class="requiredInput">
                        <div class="requiredBlock"></div>
                        <apex:inputText value="{!name}" label="Name on Card"                     
                        required="true"/>
                    </div>
                </apex:outputPanel>
            </apex:pageBlockSectionItem>

above code must be wrapped under apex:pageBlockSectionItem tag.


It is because you are using inputText. The red bar doesn't come with inputText. You might want to consider inputField to get the bar if the field is an sObject field.

See Visualforce markup used to display a required password field, with field type "password".

Tags:

Visualforce