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
NM AdminNM Admin 

field made Required on vf page not showing an error message in lightning experience?

Hello There,
I have a vf page in which I have made a field required. Please see the code below:

<apex:inputField value="{! sob[f] }" required="True"/>

This page is showing an error message on page when we leave this field empty and hit Save button in classic. But when user switch to lightning and try to do the same thing the record gets save and close the page.

I have made LightningStylesheets=true.

Can anybody help me out if what can be the reason behind it...?

Welcome to youe suggestions!

ShirishaShirisha (Salesforce Developers) 
Hi NM,

I have checked with the sample code in the VF page and it is working as expected:

<apex:page standardController="Account" > <apex:form > <apex:inputField value="{!Account.Required12__c}" required="true" Id="field4"/> <apex:inputField value="{!Account.Required123__c}" required="true" Id="field"/> <apex:commandButton action="{!save}" value="Save"/> </apex:form> </apex:page>

However,it will throw errors after clicking on the save button if the fields are empty.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future.

Warm Regards,
Shirisha Pathuri