<apex:pageBlockSectionItem >
<apex:outputLabel value="Status" for="Status"/>
<apex:outputPanel styleClass="requiredInput" layout="block">
<apex:outputPanel styleClass="requiredBlock" layout="block"/>
<apex:selectList id="chooseStatus" value="{!Contact_Exemption_ACU__c.Status__c}" size="1" required="true" >
<apex:selectOption itemValue="Approved" itemLabel="Approved"/>
<apex:selectOption itemValue="Closed" itemLabel="Closed"/>
</apex:selectList>
</apex:outputPanel>
</apex:pageBlockSectionItem>
Required red Mark on a visualforce page -自定义字段如何必填标红
最新推荐文章于 2023-10-20 11:16:37 发布
Hey, above is the code to get the red mark for an reqd attribute. Although I have used an standard field, any field can be used in the value in Select List. Also, if you need to display the error message later,following is the code.
After doing the validation in the Controller, set the errorACUheldInCustomer to true and set the errorMessage.
以上摘自https://developer.salesforce.com/forums/ForumsMain?id=906F000000095BZIAY
打开debug工具,分析:一般sfdc标准的组件,只要加上required=true就会出现如图变红的渲染效果。
在自定义的字段里是没有如图的两个div的,以上解决方法就是把连个class放出来了。