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
  • 2
  • 6

2 Answers2

1
$('id/class').attr('readonly', true);
Rory McCrossan
  • 319,460
  • 37
  • 290
  • 318
Wara Haii
  • 192
  • 1
  • 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
  • 319,460
  • 37
  • 290
  • 318
Zidane
  • 1,472
  • 3
  • 19
  • 35