Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have an application page in which two radio buttons and a people editor control is there.

My requirement is, if radio button "Yes" is checked then the people editor control should be enabled other wise it should be disabled.

My JavaScript code is:

<script type="text/javascript">
    $(document).ready(function(){   
        var radYes = document.getElementById("<%= rbtnReferralYes.ClientID %>");
        var radNo = document.getElementById("<%= rbtnReferralNo.ClientID %>");
        var peopleEditor = document.getElementById("<%= peReferralUsers.ClientID %>");
        $(peopleEditor).prop('disabled',true);
        $(radYes).click(function() {                    
            $(peopleEditor).prop('disabled',false);
        });
        $(radNo).click(function() {                 
            $(peopleEditor).prop('disabled',true);
        });
    });
</script>

My problem is that this code is working fine in IE but not working in Chrome and Firefox.

What am I missing?

share|improve this question

1 Answer 1

You can it with .attr() like this:

$(peopleEditor).attr("disabled", 'disabled');

Or you can try to hide and show with .hide() and .show() but then its completely not visible.

EDIT: You have to check if your radiobutton is checked:

    $(peopleEditor).prop('disabled',true);
    $(radYes).click(function() {                    
       if($(radYes).is(':checked')) { 
          $(peopleEditor).prop('disabled',false);
       } 
    });
    $(radNo).click(function() {
       if($(radNo).is(':checked')) { {                 
          $(peopleEditor).prop('disabled',true);
       }
    });

Radiobuttons with jQuery

Or you can use only one Checkbox for enabeling/disabling the peopleEditor field

share|improve this answer
    
thanks for answering sir, I tried this way but not working. :-( –  users1100 Mar 6 at 6:58
    
any errors for ff and chrome? –  mbauer Mar 6 at 7:06
    
No sir, I am not getting any error. I debugged the JavaScript in Firebug(in firefox). and found that the break point does not get executed placed over $(radYes).click(function() {$(peopleEditor).prop('disabled',false);}); –  users1100 Mar 6 at 7:14
    
you may have to check if the button is checked, see my edited answer –  mbauer Mar 6 at 7:20
    
I tried the edited code also, but not working sir. –  users1100 Mar 6 at 8:33

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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