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
komathipriyakomathipriya 

How to set a rich text box as Required?

Hi,

 

i used  <apex:inputTextarea richText="true" required="true" /> 

but i'm not getting any error message, if i clicked save button without any value in the text area.

but the other controle like

 <apex:inputField required="true" value="{!account.BillingCountry}"/>  workes fine.

 

 

how to set required field for rich text area??

Best Answer chosen by Admin (Salesforce Developers) 
bob_buzzardbob_buzzard

Have you got an apex:pageMessages component on the page - I've found that I don't get the red marker to indicate the field is required, but when I have apex:pageMessages and click the save button I get the validation error (albeit in quite an ugly form).

All Answers

bob_buzzardbob_buzzard

Have you got an apex:pageMessages component on the page - I've found that I don't get the red marker to indicate the field is required, but when I have apex:pageMessages and click the save button I get the validation error (albeit in quite an ugly form).

This was selected as the best answer
Devendra NataniDevendra Natani

If you use any control other than <apex:inputfield> and set the required attribute to true. The required red sign will not appear. You need to put <apex:pageMessages> component on the page. 

 

If you want to show the required sign as well please use the below code.

<div class="requiredInput">
   <div class="requiredBlock"></div>
       <apex:inputTextarea richText="true" required="true" /> 
</div>

 Please let me know if there is any issue.

 

Thanks,

Devendra Natani

Blog

komathipriyakomathipriya

Is that style classes are need to be write are default style values??

bob_buzzardbob_buzzard

They are Salesforce style classes, so they should be present as long as your page isn't excluding the standardstylesheets

komathipriyakomathipriya

Then It is not working for me.

I'm getting the error message but not the red color bar.

Sarv333Sarv333

You can try with Jquery also,

on click of submit/save button call the javascript method.

check if it is null then show the error message.

and to make your input field as required just like the salesforce std.

use the below css style sheet in your inputfield styleclass.

 

Thanks,

Sarv

 

.required{
    border-color:red;
    border-width:5px;
    border-left-style: solid;
    border-top-style:none;
    border-bottom-style:none;
    border-right-style:none; 
komathipriyakomathipriya

Thank u i ll try and reply you ASAP.

Devendra NataniDevendra Natani

I am not sure but just want to confirm. Have you written your code in below format? If yes then It will work.

 

<apex:page>
<apex:form>
<apex:pageBlock>
<apex:pageBlockSection>
<div class="requiredInput">
   <div class="requiredBlock"></div>
       <apex:inputTextarea richText="true" required="true" /> 
</div>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

 

Thanks,

Devendra Natani

komathipriyakomathipriya

yes.. i designed as same .