You need to sign in to do that
Don't have an account?
B_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: "> </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;
}
}
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: "> </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;
}
}
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