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
College ManagementCollege Management 

Can i add CSS to error message which is in addError() method ?

I've created 2 date fields (Start_Date__c & End_Date__c) and i've implemented an apex class that checks whether Start_Date__c > End_Date__c  or not if it is greater than end_Date__c then it will display an error message( i used addError(); method to display error message due to requirement of field level error message) but while getting the error message the field is going little up. I want to adjust it, Please help me out.

Thanks !
bob_buzzardbob_buzzard
You can't style the error messages I'm afraid - the HTML just gets displayed verbatim. 
College ManagementCollege Management
@Bob

Here I've created Field Level Error message, I want to display the error message which i've given in addError() method.
(ie., fieldname.addError('Start Date should not be greater than end Date'))  it below the field and i am getting it but when i am getting the error message , that corresponding field is moving a little up.
User-added image
Due to that the field alignments are missing. Please help me out.


Thanks !
bob_buzzardbob_buzzard
I'd imagine that's because the table cell is full, so the vertical alignment to the middle can't be honoured. You'll need to play with the styling of the elements on the page, although if these are standard pageblock, pageblocksection etc it will be fragile as salesforce could change the styles under you.
College ManagementCollege Management
Thanks for the reply,

<apex:form>
 <apex:pageBlock>
<table cellspacing = "3" cellpadding = "1" height="20%" width="100%" id="content" style="border-bottom:1px solid #747E96;padding-bottom:15px">
<tr>
<td style="width:2%">1</td>
<td style="width:15%">2</td>
<td style="width:2%">3</td>
<td style="width:15%">4</td>
<td style="width:26%">5</td>
<td style="width:58%">6</td>
</tr>
</table>
</apex:pageBlock>
</apex:form>
I've created in this format.  Can you tell me where to change to make it proper align.

Thanks !