You need to sign in to do that
Don't have an account?

Displaying an custom validation error on a VF page using Javascript(not by controller).
Hi All,
I need to display an custom validation error message for an 'inputText' field.
For Example:
Here, I need to display an error message if the inputText for 'Name' is null or empty.
<div style="position:absolute; top: 145px; left: 30px;" class="cnt_popup"> Name: </div> <div style="position:absolute; top: 140px; left: 105px; height:20px; width:200px;" > <apex:inputText id="name" value="{!Name}" styleClass="textarea" required="true"> </apex:inputText> </div>
Please let me know if you have any idea about how to display an custom validation error message.
Have you tried using a Validation Rule or checking the value on a Before Trigger?
You can validate inputtext value through javascript to achieve your requirement.
document.getElementById('{!$Component.pgVolReg:document:fstname}').value, this will give the value assigned to inputtext.
Here pgVolReg refer to Page id,document refer to form id and fstname refer to Input text id.
var fname = var fsname = Trim(document.getElementById('{!$Component.pgVolReg:document:fstname}').value);
if(fname == '' || fname == null)
{
document.getElementById('{!$Component.pgVolReg:document:fstname}').style.borderBottom ='2px solid #c00';
}