Skip to main content
clearify
Source Link
Yosra Nagati
  • 790
  • 2
  • 8
  • 28

How to detect the changes in input values when it is dynamically changed. as the change on txt2 clear the value in txt1 . I need to detect that it has cleared or changed.

Onchange does not do that.

<input id="txt1" type="text" onchange="SetDefault();" onpaste="this.onchange();" oninput="this.onchange();"> <br> <input id="txt2" type="text" onchange="SetDefaultSecond();" onkeyup="this.onchange();" onpaste="this.onchange();" oninput="this.onchange();"> <script> function SetDefault(){ alert("Change1"); } function SetDefaultSecond(){ $("#txt1").val(''); alert("Change2"); } </script> 

How to detect the changes in input values when it is dynamically changed. as the change on txt2 clear the value in txt1 . I need to detect that it has cleared .

Onchange does not do that.

<input id="txt1" type="text" onchange="SetDefault();" onpaste="this.onchange();" oninput="this.onchange();"> <br> <input id="txt2" type="text" onchange="SetDefaultSecond();" onkeyup="this.onchange();" onpaste="this.onchange();" oninput="this.onchange();"> <script> function SetDefault(){ alert("Change1"); } function SetDefaultSecond(){ $("#txt1").val(''); alert("Change2"); } </script> 

How to detect the changes in input values when it is dynamically changed. as the change on txt2 clear the value in txt1 . I need to detect that it has cleared or changed.

Onchange does not do that.

<input id="txt1" type="text" onchange="SetDefault();" onpaste="this.onchange();" oninput="this.onchange();"> <br> <input id="txt2" type="text" onchange="SetDefaultSecond();" onkeyup="this.onchange();" onpaste="this.onchange();" oninput="this.onchange();"> <script> function SetDefault(){ alert("Change1"); } function SetDefaultSecond(){ $("#txt1").val(''); alert("Change2"); } </script> 
Source Link
Yosra Nagati
  • 790
  • 2
  • 8
  • 28

How to detect the change on input when it changed dynamically

How to detect the changes in input values when it is dynamically changed. as the change on txt2 clear the value in txt1 . I need to detect that it has cleared .

Onchange does not do that.

<input id="txt1" type="text" onchange="SetDefault();" onpaste="this.onchange();" oninput="this.onchange();"> <br> <input id="txt2" type="text" onchange="SetDefaultSecond();" onkeyup="this.onchange();" onpaste="this.onchange();" oninput="this.onchange();"> <script> function SetDefault(){ alert("Change1"); } function SetDefaultSecond(){ $("#txt1").val(''); alert("Change2"); } </script>