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
arunadeveloperarunadeveloper 

Displaying error messages on visulaforce page

 Hi there,

 

 on visulaforce page I am having firstName, lastName, phonenumber, email  are “required=true”

 getting below validation errors , which is ok but I need to trim this message with like “FirstName required, lastname required ect”

  • locationContactPage:locationenrolmentAccountContacts:locationcontactPageBlock:locationcontactPageBlocksection:FirstNameSection:FirstName: Validation Error: Value is required.
  • locationContactPage:locationenrolmentAccountContacts:locationcontactPageBlock:locationcontactPageBlocksection:LastNameSection:LastName: Validation Error: Value is required.
  • locationContactPage:locationenrolmentAccountContacts:locationcontactPageBlock:locationcontactPageBlocksection:PhoneNumberSection:phoneNumber: Validation Error: Value is required.
  • locationContactPage:locationenrolmentAccountContacts:locationcontactPageBlock:locationcontactPageBlocksection:EmailSection:Email: Validation Error: Value is required.

.

And also In my controller if first name or last name or phone number or email is null or empty I am adding below line

ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,'Please enter the required field FirstName,LastName and Email Id'));

 

I am not getting “'Please enter the required field FirstName,LastName and Email Id” this message .

I do have <apex: messages/> on visual force page

 

Can anyone please suggest how to trim below error message

 

  • locationContactPage:locationenrolmentAccountContacts:locationcontactPageBlock:locationcontactPageBlocksection:FirstNameSection:FirstName: Validation Error: Value is required.
  • locationContactPage:locationenrolmentAccountContacts:locationcontactPageBlock:locationcontactPageBlocksection:LastNameSection:LastName: Validation Error: Value is required.
  • locationContactPage:locationenrolmentAccountContacts:locationcontactPageBlock:locationcontactPageBlocksection:PhoneNumberSection:phoneNumber: Validation Error: Value is required.
  • locationContactPage:locationenrolmentAccountContacts:locationcontactPageBlock:locationcontactPageBlocksection:EmailSection:Email: Validation Error: Value is required.

 

ForceComForceCom

Aruna, 

 

It will execute the standard error first before going through the controller. 

 

You might have to remove the condition required=true, anyway you have null check in the controller , So add a little red bar beside the field.Please find below the code to add the red bar.

 

<apex:outputPanel styleClass="requiredInput" layout="block">
    <apex:outputPanel styleClass="requiredBlock" layout="block"/>
<apex:inputfield value""/>
</apex:outputpanel>