1
<input id="in" type="text">

<script>
var input = document.getElementById("in");

input.oninput = function () {
    console.log("input");
};

input.onchange = function () {
    console.log("change");
};

setTimeout(function () {
    input.value = "test"
}, 5000);
</script>

No events worked.

How to detect input value change using JavaScript?

6
  • 1
    Close your quote <input id="in" type="text"> Commented Sep 20, 2016 at 19:00
  • Also make sure the script is in a <script> tag. Commented Sep 20, 2016 at 19:03
  • Yes, it is all done. Just this example have these mistakes Commented Sep 20, 2016 at 19:15
  • JavaScript events do not detect when the value is updated with JavaScript. Basically when you change the value, you should trigger your own custom event. Commented Sep 20, 2016 at 19:25
  • You need to trigger change event on event in setTimeout or in setTimeout always take first value or input and match value if different Commented Sep 20, 2016 at 19:36

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.