setting readonly property with Jquery

I have the following code to set a asp:textbox to read only or not.   Nothing I have tried so far works.  Any one have any ideas.

  if ($('#MainContent_hfResiType').val() == 'PayPlan') {
                $('#PayRow').hide()
                $('#txtPayAmt').removeProp('readonly')}
            else {
                $('#txtPayAmt').prop("readonly", true)
                       };

Open in new window



Here is the control html

 
 <asp:TextBox runat="server" ID="txtPayAmt" Width="100px" ValidationGroup="Checks"  CssClass="form-control mClass" TabIndex="5"></asp:TextBox>

Open in new window


The code gets hit, but nothing changes.   I have tried the attr as well.  How can I see in the google developer tools what that property Is set to.

thanks
mgmhicksAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

skijCommented:
Try this and let us know if the alerts work as expected:
  if ($('#MainContent_hfResiType').val() == 'PayPlan') {
    alert('Allow Editing');
    $('#PayRow').hide();
    $('#txtPayAmt').removeProp('readonly');
  }
  else {
    alert('Prevent Editing');
    $('#txtPayAmt').prop("readonly", true);
  }

Open in new window

0
mgmhicksAuthor Commented:
yes, does.
0
skijCommented:
Does the border color change as expected with this code?
  if ($('#MainContent_hfResiType').val() == 'PayPlan') {
    $('#PayRow').hide();
    $('#txtPayAmt').removeAttr('readonly').css('border','2px solid green');
  }
  else {
    $('#PayRow').show();
    $('#txtPayAmt').attr("readonly", "true").css('border','2px solid red');
  }

Open in new window

0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

mgmhicksAuthor Commented:
no, border did not change
0
skijCommented:
What exact HTML is being created by this?
 <asp:TextBox runat="server" ID="txtPayAmt" Width="100px" ValidationGroup="Checks"  CssClass="form-control mClass" TabIndex="5"></asp:TextBox>

Open in new window

0
mgmhicksAuthor Commented:
<input name="ctl00$MainContent$txtPayAmt" type="text" id="MainContent_txtPayAmt" tabindex="5" class="form-control mClass" style="width:100px;" />
0
skijCommented:
Your jQuery code is looking for an element with the id of "txtPayAmt" however your input has the id of "MainContent_txtPayAmt" so your jQuery code should be changed like this:
  if ($('#MainContent_hfResiType').val() == 'PayPlan') {
    $('#PayRow').hide();
    $('#MainContent_txtPayAmt').removeProp('readonly');
  }
  else {
    $('#PayRow').show();
    $('#MainContent_txtPayAmt').prop("readonly", true);
  }

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mgmhicksAuthor Commented:
You know I know that, however looking at it and looking at it, I never saw it.  Need a break!

thanks
0
Rafiq J.Net DeveloperCommented:
text box having the property. set  Readonly=true y ur trying this???
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
jQuery

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.