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 

Error message appearing twice in vf page!!!Please Help!!!!!


   I have this field (xyz)of type input text area on my visualforce page as <apex:inputField  value ="{!Opportunity.xyz__c}"/>. If i give characters more than the default limit of  text area type, Then it gives an error message , which should happen. But instead of one I am getting two error messages below that field. Can anyone please suggest me a way to rectify this issue?


Can you post here what kind of messages you are getting?
I am getting two, need just one!!!!

This message is appearing just beneath the field.


• You can't use more than 32,768 characters.

• You can't use more than 32,768 characters.







If you are using any controllers, this code give a brief idea.


Salesforce Documentation says,

ApexPages.Message myMsg = new ApexPages.Message(ApexPages.severity, summary, detail);

**where ApexPages.severity is the enum that is determines how severe a message is, summary is the String used to summarize the message, and detail is the String used to provide more detailed information about the error.



So according to salesforce there should be two parameters summary and detail. but if you skip the detail parameter, then it will displaysummary twice (not mentioned in documentation).



This expression display error message twice

apexpages.addMessage(new ApexPages.Message(, 'YOUR ERROR MESSAGE' )) ;


This expression display error message only once :smileywink:

apexpages.addMessage(new ApexPages.Message(, 'YOUR ERROR MESSAGE'  , '' )) ;




   Let me begin this by thanking you for your time and effort. Though the suggestion provided by you is quite useful for future references , it's not very much relevant to the issue here. The reason i say this is because, the error messages are nowhere coded in my controller , nor are they coming from validation rules . Its the error message that displays when your input exceeds the length of the field. So I am not very sure, how I will be able to control it in my controller. The only modification I have done is on my vf page where I have added <apex:messages/> tag at the top to display the messages.

Fasttrack Internet MarketingFasttrack Internet Marketing
salesforce1# your post was very helpful, thanks.

shrey.tyagi88@ I had the same problem although my issue was due to a message created within the controller. I think you need to add the page messages but ensure that the showDetail is set to false e.g.

<apex:pageMessages showDetail="true" />

I tried showdetail=false its not working!!!!

Hi Shrey,

How did you end up resolving the issue? I am facing a similar kind !!!

Kiran Gudadinni 1Kiran Gudadinni 1
Hi ,

Even i was facing the same issue and after checking at the known issues i found this.

Workaround provided is use the Version 28 . As this issue exists in teh versions after 28.
S i dS i d

Here is the fix !

Background : This is a very stange behaviour on <apex:inputField> with required="true" attribute and using ApexPages.Message

Root Cause : Visualforce is treating "inputField" and its parameter "label" as two different elements and hence two messages.

Code with Issue : (Where the message will display twice)

<apex:inputField value="{!newXHC.First_Name__c}" label="First Name :" required="true"/>

User-added image

Fix : 

  • Wrap the element in a pageBlockSectionItem to create groupings.
  • Separate the outputlabel and inputfield
<apex:pageBlockSectionItem >
      <apex:outputLabel title="First Name" value="First Name :" id="ATT1" for="AT1"/>
      <apex:inputField value="{!newXHC.First_Name__c}" id="AT1" required="true" />

User-added image

if this resolves your issue, thumbs up to vote the answer !

Sid (" target="_blank)

Nandakishor Chavan 30Nandakishor Chavan 30
This was really useful to resolve issue in my case. I spend around more than 2 hours on this issue but by looking your post I reolved it within 1 min.
Thank your for posting this.
Jay SrinivasanJay Srinivasan
In my case, I had two tags in my VFP
<apex:messages />
<apex:pageMessages />

Removing one resolved my issue