You need to sign in to do that
Don't have an account?
Field-level error reporting on a Sites page
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: <apex:inputText value="{!FirstName}" /><br/><br/>
<DIV class="makeRED">*</DIV>2. Last Name: <apex:inputText value="{!LastName}" /><br/><br/>
Controller:
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.'));
}
See :
http://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_message.htm
<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.name} 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>