function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SRILAKSHMI BSRILAKSHMI B 

Show popup message on VF page

Hi All,

 

I have created a Visualforce page with input fields.When user clicks on save button a logic executes in the controller and need to show up a pop message to user saying fill the values in the fields.

 

Can you please let me know how this could be acheived.

 

 

 

Thanks,

Srilakshmi B

goabhigogoabhigo

You can make use of javascript 'alert' methods. If it is making some fields mandatory then I don't see requirement of pop-up message, instead use validation rules.

symantecAPsymantecAP

Try this

<apex:page controller="popup">
    <apex:form >
        <apex:commandButton value="Show Pop up" action="{!showPopup}" rerender="popup"/>
        <apex:pageBlock >
            Lorem ipsum ..... dummy stuff to show the popup is above content
        </apex:pageBlock>
 
        <apex:outputPanel id="popup">
            <apex:outputPanel styleClass="customPopup" layout="block" rendered="{!displayPopUp}">
                Lorem ipsum <br/><br/><br/>
                <apex:commandButton value="Hide Pop up" action="{!closePopup}" rerender="popup"/>
            </apex:outputPanel>
        </apex:outputPanel>
 
    </apex:form>
 
    <style type="text/css">
       .customPopup{
            background-color: white;
            border-style: solid;
            border-width: 2px;
            left: 50%;
            padding:10px;
            position: absolute;
            z-index: 9999;
            /* These are the 3 css properties you will need to tweak so the pop 
            up displays in the center of the screen. First set the width. Then set 
            margin-left to negative half of what the width is. You can also add 
            the height property for a fixed size pop up.*/
            width: 500px;
            margin-left: -250px;
            top:100px;
        }
    </style>
</apex:page>

 

public class popup {
 
    public boolean displayPopup {get; set;}
 
    public void closePopup() {
        displayPopup = false;
    }
 
    public void showPopup() {
        displayPopup = true;
    }
}

 

SRILAKSHMI BSRILAKSHMI B

Thanks for the solution.But actualy my requirement is something like this.

I have Reject button on my VF page page when user clicks on the reject button without entering in the Rejection reason field I should show Alert message to him.I think I need to use the javascript here.

 

Could please provide me with code snippet to acheive this.

 

Thanks,

Srilakshmi B

SFDC_LearnerSFDC_Learner

To achieve this,

 

We can use window.showModalDialog('popuppageurl') method.

 

 

function fun()

{

window.showModalDialog('/apex/newpage');

}

 

 

<apex:form>

  <apex:commandButton value="Popup" action="{!dosomeaction}" onclick="fun()" />

</apex:form>

 

 

Like this you have to use.

harsha__charsha__c

Write a javaScript function displaying on what field you want with a condition

 

 

 

and diaplay message with alert("******  The Message  **************");

NasirNasir
Hi @symantecAP
Thanks for this suggession. I have implemented the same and it worked.

Thanks
Nasir Jawed