You need to sign in to do that
Don't have an account?

To Display Error Messages..
Hai All,
I have small Doubt,
How to display Error message Under a Custom field(not SObject field) or item in Visualforce through Apex.
You need to sign in to do that
Don't have an account?
Hai All,
I have small Doubt,
How to display Error message Under a Custom field(not SObject field) or item in Visualforce through Apex.
<apex:page controller="exampletest">
<apex:form >
<apex:pageBlock >
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!save}" />
</apex:pageBlockButtons>
<apex:pageBlockSection >
<apex:pageBlockSectionItem >
<apex:outputLabel value="Required Field" />
<apex:outputPanel styleClass="requiredInput" layout="block" >
<apex:outputPanel styleClass="requiredBlock" layout="block"/>
<apex:inputText value="{!requiredFieldName}" />
</apex:outputPanel>
</apex:pageBlockSectionItem>
<apex:pageMessages />
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
public class exampletest {
public String requiredFieldName {get;set;}
public void save(){
if ( requiredFieldName == null || requiredFieldName == '' ){
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Please enter a value in the Required Field'));
}
}
}
Hai premnath,
Thanks for ur reply.I need to display under the field itself.I had 20 number of custom fields.
As according to you that error message will display where evere we put PageMessage in the page.
Your question is not yet clear.
Error messages means how can you get ,,, What is the pur pous of that messages
you mean required or something else
Hi,
You can't place Error message under every field by using normal tags of SF in VFP's
However if you need to achieve this you need to use HTML script at each field to disply that error message.
which need a bit custom coding in HTML.
<apex:inputfield ......>
<div class="errormessage" style="display:none;" id="errmsg"><strong>Error:</strong> Error Message</div>
Currenty i don't have any sample script to give to you.