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
KD119KD119 

Unable to set the Required block for input text

Hi,

 

I am trying to get the required field setup for a inputText. I have tried methods provided but they do not provide the same feel.

<apex:outputLabel style="font-weight:bold" value="Company Name" for="companyName"/>
<apex:outputPanel>
	<div class="requiredInput">
                   	<div class="requiredBlock"></div>
                                     <apex:inputText style="height:20px;width:200px" id="companyName" value="{!companyName}" required="true"/>
	 </div>
</apex:outputPanel>

 Any pointers on how I can get the required block style for this.

 

Thanks

KD

bob_buzzardbob_buzzard

Do you have this inside a pageblock/pageblocksection?  I've found that's the way that I get the red marker to appear, and pageblocksection allows me to get the label and the input text on the same line.

KD119KD119

Hi,

 

I have tried to nest it within PageBlockSection as well as PageBlockSectionItem. I simply don't seem to get the feel in the UI. I am using Custom CSS in the page for many components. Would this cause any issues when calling a class that is native to visualforce?

 

Thanks

KD

bob_buzzardbob_buzzard

Only if you've clashed names with a Salesforce class I think.

 

How does it differ from the standard salesforce - is there no red bar, across two lines or something else?

KD119KD119

There are no redbars being shown in the UI. I have verified if I had used the required  class names in my CSS and the result is Negative. Should we be adding any line that includes the Salesforce css into the visualforce page?

 

Thanks

KD

KD119KD119

I had inintially set the StandardStyleSheet attribute in apex:page as false. Thought maybe that is causing the issue and changed the value to true, still there is no redbar showing up.

 

Thanks

KD

Ankit AroraAnkit Arora

This is not working for you ??

 

<apex:page>
<apex:form>
    <apex:pageBlock>
    <apex:outputLabel style="font-weight:bold" value="Company Name" for="companyName"/>
    <apex:outputPanel>
        <div class="requiredInput">
            <div class="requiredBlock"></div>
            <apex:inputText style="height:20px;width:200px" id="companyName" value="{!companyName}" required="true"/>
         </div>
    </apex:outputPanel>
    </apex:pageBlock>
</apex:form>
</apex:page>

 

Thanks

Ankit Arora

Blog | Facebook | Blog Page

KD119KD119

Yes the solution of adding the Requireblock does not bring the red bar against the field. So currently I am trying using the basic * marker for the required field marking which looks very out of place.

 

Thanks

KD

Ankit AroraAnkit Arora

This is strange, can you please provide your entire visualforce page code so we can find out where is the problem.

 

 

Thanks

Ankit Arora

Blog | Facebook | Blog Page

Siddharth Birari.ax1164Siddharth Birari.ax1164

This won't work unless you include the code in a pageBlockSection

 

<apex:pageBlock mode="edit">
    <apex:pageBlockSection >
    <apex:pageBlockSectionItem >
        <apex:outputpanel layout="block" styleClass="requiredInput">
            <apex:outputpanel layout="block" styleClass="requiredBlock"></apex:outputpanel>
                <div class="topSpacing leftSpacing"><apex:inputField value="{!oAccount.Particular_Aspects__c}" styleClass="leftSpacing"/></div>
            </apex:outputpanel>
      </apex:pageBlockSectionItem>
      </apex:pageBlockSection>
</apex:pageBlock>