1

Following is my javascript code,is there a way to make checkbox and textbox readonly?

//display textboxes and checkbox when condition is true.
if($$("id").value =="something"){
       document.getElementById("textboxl").style.display="";
        document.getElementById("chkbox1").style.display="";
        document.getElementById("textbox2").style.display="";
        document.getElementById("chkbox2").style.disable="";
    }

I have to display and then disable it(i mean make it readonly).

1
  • (Among other things)I added the jQuery tag as it looks like you're using it. Commented May 10, 2012 at 12:10

1 Answer 1

1

Update:

element.readOnly = true

Set readonly with:

$('#chkbox1').prop('readonly', true);

Or:

$('#chkbox1').attr('readonly', 'readonly');

display can be done with:

$('#chkbox1').show();

Or with:

$("#chkbox1").css('display', 'block');
Sign up to request clarification or add additional context in comments.

3 Comments

:thanks for the reply..i`m sorry for informing this late,plz check out the question i have changed.
:We are using '$' as a function just to avoid rewriting 'document.getElementById'.
$("AprEmail2").disabled=true; $("chkApp2").disabled=true; this thing worked for me

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.