How to detect change in value of input with readonly active

0

HTML:

<!-- Campo preenchido com retorno AJAX -->
<input type="text" name="estado-cliente" hidden id="estado-cliente"  readonly="readonly"/>

How do I stop detecting any change in value ?

Note: value is added and changed via JS

Unsuccessful with the snippet below :

$("#estado-cliente").bind("change paste keyup", function() {});
    
asked by anonymous 05.03.2017 / 20:05

2 answers

0

Try to put this jQuery to run at the top of the page:

$(document).ready(function () {   
   $('input#estado-cliente').bind("change", function () {
      alert($(this).val());
   });
});

If you need to simulate the exchange of values:

$('#estado-cliente').val('teste').change();
// Senão funcionar da forma acima tente assim
$('#estado-cliente').val('teste').trigger('change');
    
05.03.2017 / 20:14
0

Add on your JavaScript the following

$("#estado-cliente').on('change', function () {
  alert("Estão tentando alterar");
});
    
06.03.2017 / 20:39