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
ezhil_kezhil_k 

how to make a vf page with the input fields "read only"?

Puja_mfsiPuja_mfsi

Hi,

you can use java scrip in onload of a page and set the attribute 'readOnly' to true for inputField.

 

Let give me an example:

 

<apex:page standardController="Account" id="thePage">
        <apex:form id="theForm">
              <apex:pageBlock id="theBlock">
                     <apex:pageBlockSection id="theSec">
                                    <apex:inputField value="{!Account.name}" id="accName" />
                     </apex:pageBlockSection>
              </apex:pageBlock>
              <script>
                       function setResult(){
                                    document.getElementById('thePage:theForm:theBlock:theSec:accName').readOnly=true;
                        }
                       window.onload = setResult;
                </script>
         </apex:form>
</apex:page>

 

Please let me know if u have any problem on same and if this post helps u give KUDOS by click on star at left.

ezhil_kezhil_k

Thanks for your reply ! is there any option that can be made in vf tag as read only?

 

ezhil_kezhil_k

Here is my code.Once I click Review butoon ,i want to make the input feilds to read only..

 

<apex:page standardController="Application__c" extensions="app">
    <h1>Application Form</h1>
   
    <apex:form >
        <apex:pageMessages id="error"/>
        <apex:pageBlock >
        <apex:pageBlockSection title="Information">
       
        <apex:inputText value="{!Application__c.Name}"/>
        <apex:inputText value="{!Application__c.Candidate_Name__c}"/>
        <apex:inputText value="{!Application__c.Age__c}"/>
        <apex:inputText value="{!Application__c.Address__c}"/>
        <apex:inputText value="{!Application__c.Contact_Number__c}"/>
        </apex:pageBlockSection>
         <apex:commandButton value="Review" />


      </apex:pageBlock>
    </apex:form>

    </apex:page>

KaityKaity

When we create the field,in FLS(Field level Security), check the field as read only. And since you are using <apex:inputField>, the field will reflect as 'READ-ONLY'.  

 

-Kaity

KaityKaity

Hi,

 

You can also use <apex:outputfield> tag, to make a field read-only.

 

-Kaity.

Nihar AletiNihar Aleti
Hi,
use the folowing 
<apex:inputText value="{!Account.Name}" html-readonly="true" />
sumat srivastav 6sumat srivastav 6
Hi Nihar, can we set this value true/False using boolean variable. I have tried but it is not working
Nagesh Rajmane 9Nagesh Rajmane 9
use html-disabled="true" in apex:inputfield this will work fine