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

Field-level error reporting on a Sites page

Hi all,  I'm hoping you can shed some light on if this is possible.  I'm developing on Sites, and I'm currently doing error reporting via <apex:pageMessages>; all my errors appear at the top of the page.  What I really want is to make each error appear at the associate field.  I know I could make out outputText and pass over the error message text, but I'd really like to use the Salesforce formatting for error messages.  Any ideas?  Code below...


Sites Page:


<apex:page id="pg" controller="ControllerAccount" action="{!DoLoad}" title="Welcome to Parent Pulse" sidebar="false" showHeader="false" cache="false" standardStyleSheets="true">

<apex:form id="frm">
<c:ParentHeader />
<apex:pageMessages />

<DIV class="makeRED">*</DIV>1. First Name:&nbsp;<apex:inputText value="{!FirstName}" /><br/><br/>

<DIV class="makeRED">*</DIV>2. Last Name:&nbsp;<apex:inputText value="{!LastName}" /><br/><br/>




if(FirstName == null || FirstName.trim() == ''){
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,'1. Please enter your first name.'));

if(LastName == null || LastName.trim() == ''){
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,'2. Please enter your last name.'));






David VPDavid VP

See :



<apex:page controller="MyController" tabStyle="Account"> <style>.locationError { color: blue; font-weight: strong;}.employeeError { color: green; font-weight: strong;} </style> <apex:form > <apex:pageBlock title="Hello {!$User.FirstName}!">This is your new page for the {!name} controller. <br/>You are viewing the {!} account. <p>Number of Locations: <apex:inputField value="{!account.NumberofLocations__c}" id="Location_validation"/> (Enter an alphabetic character here, then click Save to see what happens.) </p> <p>Number of Employees: <apex:inputField value="{!account.NumberOfEmployees}" id="Employee_validation"/> (Enter an alphabetic character here, then click Save to see what happens.) </p> <p /> <apex:commandButton action="{!save}" value="Save"/> <p /> <apex:message for="Location_validation" styleClass="locationError" /> <p /> <apex:message for="Employee_validation" styleClass="employeeError" /> <p /> </apex:pageBlock> </apex:form> </apex:page>