+ Start a Discussion

Validation Error Message



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"/>



    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) 



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.