How to enable a textbox in jquery? [closed]

-2

What I need is for a textbox to be disabled and enabled until I write 4 numbers in a previous textbox. The textboxes are asp: Textbox. The truth is I have not tried it because I do not know how, and it occurs to me that it could be with jquery or from the behind code c #. Thanks for reading.

    
asked by sunflower 07.04.2018 в 19:28
source

1 answer

0

For this I would use the keyup

event

Documentation jQuery keyup () Method

I hope it serves you

$("#txt1").keyup(function() {
  var _this = $(this);
  if (_this.val().length >= 4) {
    $('#txt2').removeAttr("disabled");
  }else{
    $('#txt2').attr("disabled", "disabled");
  }
});
input[disabled] {
  background-color: #eee;
  cursor: not-allowed;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="textbox" id="txt1" placeholder="Escribe ...">
<input type="textbox" id="txt2" disabled>
    
answered by 08.04.2018 / 02:26
source