Monday, April 1, 2013

Required Information / Required Field Mark

This time I explore a small but useful code, Some time we have validate the input text boxes using Jave Script or using required attribute but we didn't mark as Required field like a Salesforce required field red mark -



Using this code you can mark any <apex:inputText />  , <apex:inputField/> , <apex:inputTextarea/> , <apex:selectCheckboxes> , <apex:selectList> ....etc.

I have written a code for only <apex:inputText />

<apex:page>
  <apex:form>
      <Apex:pageBlock>
          <Apex:pageBlockSection>
              <Apex:pageBlockSectionItem>
                    Field Label                     <!-----Enter here field label ------>
                    <apex:outputPanel >
                      <div class="requiredInput">
                             <div class="requiredBlock"></div>
                             <!---- APEX / HTML Tag which you marked a required------>
                            <apex:inputText required="true" id="reqField" />          
                     </div>
                   </apex:outputPanel>
             </Apex:pageBlockSectionItem>
         </Apex:pageBlockSection>
      </Apex:pageBlock>
  </apex:form>
</apex:page>






10 comments: