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
PrattyPratty 

How to display error message on right side of inputText.

 

Hi,

 

I have inputText component for accepting input.

 

If user not fills any value I want to display error message to right side of this field.

 

I made required = true but it displays error message on top of page.

 

Here is code,

 

<apex:inputText id="username" value="{!username}" styleClass="textSmall" required="true"/>

 

Could you please help me to get through this.

 

Regards,

 

Pratty

amit123amit123

public class CustomAccount{
    public static void isAccountExist(Custom_Account__c[] account) {
        System.debug('inside isAccount');
        System.debug('Array First Element------>' + account[0].Name );
        List<Custom_Account__c> list1  = [select Name from Custom_Account__c where Name =:account[0].Name];
        System.debug('value of ------->' + list1.size());
        if(list1.size()> 0)
        {
          System.debug('user already exist');
          account[0].Name.addError('AccountName Already Exist, Please use another name');
        }
        else
        {
          System.debug('new entry Testing');
        }
              
    }
}

PrattyPratty

Hi,

 

Thanks for reply but I want that error message for "inputText" component.

 

Here's is complete code.

 

// controller

 

public string username {get;set;}

 

// Page

 

<apex:inputText value="{!username}" />

 

if I used addError method for username it shows error message that it's only used for sObject fields.

 

Regards,

 

Pratty