0

I am using a combination of knockout and jquery and I would like to know how I can make a textbox readonly in either knockout or jquery

Shumba Soft
  • 97
  • 3
  • 7

2 Answers2

1
$('id/class').attr('readonly', true);
Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339
Wara Haii
  • 202
  • 2
  • 5
0

Hi there you have not shown us what you have tried so far, however, I have listed a knockout and jquery example that might be useful to you. You can also have a look at this link for further clarification.

<!-- ko if: if your condition is met  -->
  <input type="text" class="input-xlarge" data-bind="value:  texboxValue" id="textboxID"  />
<!-- /ko -->

<!-- ko ifnot: if your condition is not met -->
  <input type="text" class="input-xlarge" data-bind="value:  texboxValue" id="textboxID" textboxName" readonly />
<!-- /ko -->

Then on the jQuery side:

// this will make you textbox readonly
$("#textboxID").attr('readonly', 'readonly');

// this will remove the readonly attribute from your text box read/writeable
$("#textbox").removeAttr('readonly');
Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339
Zidane
  • 1,696
  • 3
  • 21
  • 35