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
B_kB_k 

Required Mark next to Apex:inputText and showing required error message

How to add message next to Apex:inputText and showing required error message.


My Visualforce Page
               <div> <label>Your Name</label> </div>
            <apex:inputText value="{!Case.SuppliedName}" html-rows="1" html-cols="20" style="width: 200px !important;" required="true" />
<div style="width: 500px; background: ">  &nbsp;</div>

MyPageController
public class CaseControllerExt {
    private final Case acase;
    public Blob afile {get; set;}
    public String contentType {get; set;}
    public String fileName {get; set;}
    public CaseControllerExt(ApexPages.StandardController stdController){
        this.acase=(Case)stdController.getRecord();
        acase.Status = 'New';
        acase.Origin = 'IT Request Form';
    }
    public PageReference createCaseWithAttachment() {
        try{
            insert(acase);
        }catch(System.DMLException e){
            ApexPages.addMessages(e);
        }
        if(afile!=null){
            Attachment attach=new Attachment();
            attach.Body=afile;
            attach.Name=filename;
            attach.ContentType=contentType;
            attach.ParentID=acase.id;
            try {
                insert(attach);
            } catch(System.DMLException e) {
                ApexPages.addMessages(e);
                return null;
            }
        }
        PageReference p = Page.Confirmpage;
        p.setRedirect(true);
        return p;                    
    }        
}

Screenshot
 
PriyaPriya (Salesforce Developers) 

Hey 

Here is the exactly what you are looking for :- 
https://salesforce.stackexchange.com/questions/157959/required-mark-next-to-apexinputtext-and-showing-required-error-message

Kindly mark it as the best answer so that it can help others as well.

Thanks & Regards,

Priya Ranjan