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
softcloud2009softcloud2009 

Validation Error Message

Hi,

 

I put some validation on our visual force page, but our validation message has some id which i don't know how to disable it. The message is something like this:

 

  • j_id0:j_id2:j_id32:j_id36:SerialNumber: Validation Error: Value is required.
  •  

    And here is my visualforce code for that particular textbox:

     

    <apex:actionRegion >
                        <apex:outputLabel value="Enter Serial Number:" style="font-weight: bold;" for="SerialNumber"/>&nbsp;
                        <apex:inputText value="{!inSerialNumber}" required="true" id="SerialNumber"/>&nbsp;
                        <apex:commandButton value="Go" action="{!action}" rerender="dynamic"/>

    </apex:actionRegion>

     

    And this is my controller:

     

    if (inSerialNumber == null || inSerialNumber == '')
            {
                ApexPages.addMessage(new ApexPages.message(ApexPages.severity.FATAL, 'Please enter a value in serial number field.'));
            }

    How to remove that random id in front of the validation message?

    Thanks much.

     

     

     

Best Answer chosen by Admin (Salesforce Developers) 
crop1645crop1645

softcloud2009

 

ah yes -- the problem is the required="true" on your inputText component

 

VF only displays meaningful 'required field is missing' messages on inputField components (i.e. tied to an SObject field, not an arbitrary VF controller property)

 

Since your controller is already testing for non-null, you can safely remove the required="true".  You will lose the red bar though next to the field on the page.