[SalesForce] override Standard Save Button (with a visualforce page) on Standard page of a Custom object

The requirement is to show some messages after Save. Messages would depend on the fields entered for custom object record. The best way which I figured would be to override the standard Save button on the custom object to a visualforce page which would display appropriate messages and then perform save.
Not sure how to do that. Please help.

Best Answer

Add a field, hidden, of course, that should be set when a message should be displayed. Then, add a hidden Visualforce page to the layout that should reset the flag and show a message when appropriate. The flag can be set from a trigger.

trigger X on Y (before insert, before update) {
    for(Y r: Trigger.new) {
        r.Flag__c = r.Field__c == 'Some Value';
    }
}

Page:

<apex:page standardcontroller="Y" extensions="yExt" action="{!resetFlag}">
    <script>
    if({!showmessage}) {
        alert("Some informational dialog");
    }
    </script>
</apex:page>

Extension:

public class yExt {
    ApexPages.StandardController c;
    public Boolean showMessage { get; set; }
    public yExt(ApexPages.StandardController ctrl) {
        c = ctrl;
        showMessage = ((Y)ctrl.getRecord()).Flag__c;
    }
    public void resetFlag() {
        ((Y)c.getRecord()).Flag__c = false;
        c.save();
    }
}

Drop this into a page layout with a zero-height frame (will make it effectively invisible), and you've got your message alert.

This is only a very basic framework; you might want to make some adjustments based on your exact requirements.