I have a simple visualforce page like so…
<apex:page controller="MerchantDetails">
<apex:form >
<apex:pageBlock title="Confirm or solicit the fields below">
<apex:pageMessages />
<apex:pageBlockSection>
//data...
<apex:inputField label="Date of Birth" value="{!contact.Birthdate}" required="true"/><br />
//more data...
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
For the input fields where the required and label attributes are set, the pageMessages will write out duplicate messages. For example…
Errors
Date of Birth: Invalid Date
Birthdate: Invalid Date
Notice that pageMessages thinks it needs to say it is an invalid date for the label attribute and the value attribute. I only want one of the messages to be displayed. Why would salesforce write both messages? Is there something I am doing wrong? What is the best way to handle this?
Best Answer
One way to handle this would be to use a separate apex:outputLabel. E.g.
This doesn't really address why you are getting double validation page messages.
One thing I did find. If you change the label attribute to match the field label of the field you only get one validation message. By this stage you could just exclude the label attribute entirely and use Christopher's suggestion to customise the label everywhere.