I want to customize the error msg which comes like: when i give wrong format of email id to email field so on below the fields error appear Error: Invalid Email Address.

at the same time in debug log this appears :
VF_PAGE_MESSAGE|Invalid Email Address.
VF_PAGE_MESSAGE|Email: Invalid Email Address.

is there a way to get these message in some variable so i can show them in my customize UI ? as well i want to render a particular section of page based on some variable, that variable should know does it have a exception/validation message or not.


You can access all validation messages of the current context by using this code


which return a list of Apex.Message Object. You can use this in your controller to write a debug log or to customize the display of your message without using the default component

<apex:messages />


<apex:message />
  • Here problem comes, bcz for field validation, controller is not called. So we can't use ApexPages.getMessages(). – Ankuli Oct 27 '15 at 5:26
  • I thing I'm not getting you. Salesforce validate data only upon an save operation. And this Can not be done in VF without a call to a controller action. If you only want client side validation , I thing you will have to implement it manually because I dont know a way to access salesforce validation messages without a save context. – Genoud Magloire Oct 27 '15 at 6:13

Put an <apex:messages /> tag on your page. You can style it as you want.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.