+ Start a Discussion
Mahesh Babu 3Mahesh Babu 3 

Display standard validations on VF page

Hi All,

I am trying to display the standard validation messages on VF page by using page messages components. My code is in below,

VF page:
<apex:pagemessages escap="false" />
   <apex:inputtext value="{!contactemailvalue}" />
<apex:commandbutton action="{!contactSave}" value="Save Cont" />

Public string contactemailvalue {set;get;}
public pagereference contactsave(){
contact contemp = new contact();
contemp.lastname = 'Sample Contact';
contemp.email.com = contactemailvalue;

catch(Exception ex) {   
            System.debug('Error inside catch block');
            return null;

Sample: In this, if user provided wrong format of email then showing the error message like in standard format refer the belowUser-added image

My Requirement is to show the only content of the validation message. From above example i want to show only this message
"invalid email address: asasbvudfeyg"

Please help me to solve this 

I've written a couple of blog posts on this in the past at: 




do these help? I suspect you'll either have to parse the exception message yourself or duplicate your validation inside the apex controller.