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

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:form>
<apex:inputtext value="{!contactemailvalue}" />
<apex:commandbutton action="{!contactSave}" value="Save Cont" />
<apex:form>
Controller:
Public string contactemailvalue {set;get;}
public pagereference contactsave(){
try{
contact contemp = new contact();
contemp.lastname = 'Sample Contact';
contemp.email.com = contactemailvalue;
}
catch(Exception ex) {
apexpages.addmessages(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 below
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 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:form>
<apex:inputtext value="{!contactemailvalue}" />
<apex:commandbutton action="{!contactSave}" value="Save Cont" />
<apex:form>
Controller:
Public string contactemailvalue {set;get;}
public pagereference contactsave(){
try{
contact contemp = new contact();
contemp.lastname = 'Sample Contact';
contemp.email.com = contactemailvalue;
}
catch(Exception ex) {
apexpages.addmessages(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 below
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
http://bobbuzzard.blogspot.co.uk/2011/04/field-level-error-messages-with.html
and
http://bobbuzzard.blogspot.co.uk/2011/04/field-level-error-messages-with_29.html
do these help? I suspect you'll either have to parse the exception message yourself or duplicate your validation inside the apex controller.