I have a textarea which i'm trying to disable using the below code via JQuery read function

jQuery( document ).ready( function(){
  jQuery( 'input[id$=oprm12]' ).prop('disabled', true);   //Works for text field
  jQuery( 'input[id$=oprprob]' ).prop('disabled', true);  //Does not works for text area

The function works for text field but not for textarea field. Any inputs on how to fix this please?

  • The reason this wasn't working for you in all cases is because you were using invalid markup. disabled is the name of an attribute, not a property as you've got it written. The value of true is also not correct per the spec. 'disabled' is correct. stackoverflow.com/a/6961821/1947121
    – Mark Pond
    Dec 7 '15 at 16:27

try with this

jQuery('input[id$=oprm12], textarea').attr('disabled','disabled');
jQuery('input[id$=oprprob], textarea').attr('disabled','disabled');

Above code make all the text area to disabled

-- So javascript solution

document.getElementById('{!$Component.oprm12}').disabled = 'disabled';
document.getElementById('{!$Component.oprprob}').disabled = 'disabled';

Tested with above code working for me

  • Thanks Ratan, tried but still doesnt work during the load event Dec 7 '15 at 11:43
  • are you using apex:inputfield or apex:inputTextarea ? pls add you code
    – Ratan Paul
    Dec 7 '15 at 11:56
  • @PrabhuSethupathy check my updated ans. Use .attr('disabled','disabled');
    – Ratan Paul
    Dec 7 '15 at 12:02
  • Thanks it worked now. Shud i use .attr when handling the textareas? I see .prop('disabled', true) working for textfields but not for textareas? Dec 7 '15 at 13:18
  • looks like you have specify $('input[id$=txtArea], textarea').prop('disabled','disabled'); textarea then only it is working
    – Ratan Paul
    Dec 7 '15 at 13:23

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.