I have a parent account field with a magnifying glass on the right side of it. I need to users to only click on the magnifier glass and search for the parent and not type in the field . Most of the time they spell it wrong and they wont click on the magnify glass and they get error.

 <apex:pageBlockSectionItem rendered="{!IF($UserRole.Name =='Channel Manager' || $UserRole.Name == 'Outside Sales Director' ||$UserRole.Name == 'Salesforce Administrator', true , false)}" >
        <apex:outputLabel value="Parent Account" for="acctparent" />
        <apex:inputField id="acctparent"  styleClass="acctparent" value="{!account.ParentId}"  />

            <apex:pageBlockSectionItem >

I have tried javascript and didnt work





$("input[id*='acctParent']").prop('readonly', true);

i tired

<apex:outputPanel rendered="{!onOff}">
<apex:inputField value="{!someField}"/>

didnt work

I tried


I found a solution i guess I can use this


<apex:inputField id="acctparent"  styleClass="acctparent" value="{!account.ParentId}"  html-disabled="true"  />

and as a secondary way if you have onchange on your button, use the following

onfocus="this.blur" onkeypress="this.blur()"  onchange="getSobjectList()"
| improve this answer | |
  • If you would have read the comments your issue was simply a case sensitive issue. your jQuery would have worked had you used acc p arent with proper placement – Eric Dec 9 '16 at 1:55
  • 1
    the one on Mark Pond does not seem to work while html-disabled="true" is definitely the answer !!..Thanks Meta – Aaron Wilfred Jun 9 '17 at 3:40
  • 5
    this answer is rather misleading. the disabled attribute is not a boolean. if you set disabled="false" it will still be disabled – TemporaryFix Jul 18 '19 at 16:17

I think a better solution is to use <apex:outputField>.


| improve this answer | |

JavaScript is case sensitive. <apex:inputField id="acctparent" has a lowercase p in the id value, your selector rule has an uppercase P. $("input[id*='acctParent']")

Correct that and you'll probably be in business.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.