Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a visualforce page which has a apex:pagemessage tag. A method on the controller is checking if a field in the visualforce page is valid.

I want to display an error message but I do not want to use apex:pagemesssages.Can someone give me an example to do so.

It would be really helpful.Thanks

share|improve this question
up vote 6 down vote accepted

You can overwrite the standard salesforce error message css classes. In my example i have a simple error message with only short summary and a custom icon. So i took all error css classes and changed the icon. Then i have wrapped my message in a outputPanel and edited the message class (but only for this output panel): removed background and border. You can pack that two css classes to the static resource and include on your pages. Don't forget to wrap the custom message into the output panel:

<style>
.errorM4 .msgIcon, .errorSmall {
    background-image: url(/img/samples/flag_red.gif) !important;
}

.myCustomMessage .message {
    background: none  !important;
    border: none !important;
}

</style>

    <apex:outputPanel styleClass="myCustomMessage">
        <apex:pageMessage severity="error"
                          strength="1"
                          summary="Some error text" />
    </apex:outputPanel>

enter image description here

Or a different hack is hide the standard error message using display none and oncomplete call a custom message now get the body of error message if it contains a message then display the message in alert box or if you are using Bootstrap then model . These are two option which you can use.

share|improve this answer
    
Thanks..that was really helpful – Rimii Jan 4 at 5:52

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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