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
john.krjohn.kr 

Hi All ! How to Give validation rule From object to custom visulaforce page

Take an example Student__c is an object and in that object having fied called Age__c.Then i have created validation rule on student object the age less than 18 the validation rule fire.It's working on standard page.now i have created custom visulaforce page with student object fields then i enter the data into the fields the validation is not fired.validation is an active mode but on custom visual force page the validation not working any idea thanks..................

jungleeejungleee

Hi,

 

Use the <apex:pagemessages/> tag your vf page if you have selected the Error Location option in the validation rule as Top of the Page. And if you have selected the option as Field, then the validation error message will appear whereever you have used that particular field using the tag<apex:inputField/>

 

Hope this help!!

-Sam

john.krjohn.kr

I have selected the Error Location option in the validation rule as Field and i used <apex:pagemessages/> tag on vf page and also i have used <apex:inputField/> on page for that field but error msg not showing on page,the page is a visualforce page popup.

jungleeejungleee

I am not sure why you're unable to get the error messages.. Can you please share the code??

N.V.V.L.Vinay KumarN.V.V.L.Vinay Kumar

Hi,

 

you cannot get the validation message on the page because it will be as an exception in Debug Log you can this

So to get this message on the page you should shouls use Try ctach block in the code

 

otherwise check same condition in the controller and use Apex.Pages.addMessage to display on the VF page