I have a apex:inputText field which is disable in following 2 ways

  1. <apex:inputText Id="pBSId" value="{!pBSId}"  disabled="true"/>
      <apex:image value="/s.gif" StyleClass="lookupIcon" style="cursor:pointer;" onclick="openLookupPopup();"/> 


  2. <apex:inputText Id="pBSId" value="{!pBSId}" />
     <apex:image value="/s.gif" StyleClass="lookupIcon" style="cursor:pointer;" onclick="openLookupPopup();"/> 
        <script>document.getElementById('{!$Component.pBSId}').disabled =true; </script> 

by using lookup i was passing values to this field.But manually user can not edit values.

The only problem i was facing is when any validation fails in controller it will through error messages to visual force pages.At this time all field values which were entered previously were holding, but this field is loosing it's old value and displaying empty field.But if i rempve disable(true) it is holding value.

I was wondering is there any way to achieve these two,like have to hold previous value and to disable the field from any manual edits other than selecting from lookup window. enter image description here

  • 3
    can u check if the value {!pBSId} being cleared anywhere.. I jus tried a simple VF with a standard controller & inputtext binding to a standard field and the 1st option definitely retains the value during validation errors. Jun 14, 2015 at 14:10
  • Thanks...surely..i will check,but i was wondering when i removed disable attribute..it's working fine...
    – Rajasekhar
    Jun 14, 2015 at 16:53

3 Answers 3


Try using readOnly attribute rather than disabled. A read-only input field cannot be modified, but are still submitted with the form. So your code will look like this.

<apex:inputText Id="pBSId" value="{!pBSId}"  readOnly="true"/>

Hope this will help.


you can use html-readonly="true" to make inputText as disable and also pass value to server side.


Use html-disabled

<apex:inputField Id="pBSId" value="{!pBSId}" html-disabled="true" />

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .