How can we show indicator for required field in VF page, There is always a red indicator , I want to have some other color indicator against the fields, I am using outputfield to show the values and not successful to show any kind of indicator except having onemore field outputtext but it seems not working for me

Example :

    .myRequired {background-color: #CC0000;margin-right: 2px;display: inline;width: 3px;float: left;}
      <apex:inlineeditsupport ShowOnEdit="save,cancel" event="ondblclick">
        <apex:pageBlockSection columns="2">

         <apex:outputfield value="{!Account.NaicsCode}" styleclass="myRequired"/> 
<apex:outputfield value="{!Account.NaicsDesc}" styleclass="myRequired"/

It does not show that red bar beside outputfield as it is inline editing, I cannot use the inputfield.

If I use outputtext then it does show the red bar.

How to get red required field indicator to show when using inline edit support?

I have referred the following link but it does not solve the issue of having a required indicator for outputfield


1 Answer 1


With a bit of css and the proper tag: Example below

<apex:page standardController="Account">
    background-color: yellow !important;

<apex:form >
<apex:pageblock >
<apex:pageblocksection >
<apex:inputField value="{!account.name}"/>


Of course if you get more specific with your selectors you may not need the !important flag

  • Thanks, Yes I was using this kind of inline css <style> .mycs {background-color: #CC0000;margin-right: 2px;display: inline;width: 3px;} </style> but the problem it is not reflecting on outputfield, though it does show on outputtext.
    – Ashish
    Jul 27, 2015 at 19:21
  • Required marks in SF only show up in inputFields. You can roll your own if you need it on an output field so your question is a bit unclear. Post an example as an edit to your question of this page that is doing what you want just with the wrong color
    – Eric
    Jul 27, 2015 at 19:47
  • Done, Iam using outputField field due to inlined editing functionality, I want to place a green or red bar beside the outputField field
    – Ashish
    Jul 27, 2015 at 19:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.