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
VirijaVirija 

How to display a warning message using Visualforce Page.

Hi,

 

I have a picklist field called Job Category. The user can select any value in the picklist but the user cannot edit or delete some categories once they are selected. This functionality is done using triggers and validation rules. I want a visualforce page that should display a warning message "Job category of this type cannot be edited or deleted. Do you want to Proceed?" I want this page to be displayed when the user selects any one of the picklist value that cannot be edited or deleted. Can some one please provide the code for VF page that provides this functionality??

 

Thank You in advance for the help.

Jeff MayJeff May

In your Visual Force page, you can use the 'onchange' event for your <apex:inputText>

 

Then, in your controller method tied to the "onchange", you can check to see what the user selected, and add a Page Message. 

 

Here is the skeleton

 

VF Page:

 

<apex:inputText value="{!theFieldValue}" style="width:70px" required="false" >
<apex:actionSupport action="{!checkInfo}" status="StatusChange" event="onchange" rerender="thePanel"/>
</apex:inputText><br />

 

 

Controller:

 

public String theFieldValue {get;set;}

 

public PageReference checkInfo(){

  if (theFieldValue == 'A') {

     ApexPages.Message errormsg = new ApexPages.Message(ApexPages.severity.ERROR,'Value not allowed');

  }

 

  return null;

 

}