Detect changed input text box Detect changed input text box jquery jquery

Detect changed input text box


You can use the input Javascript event in jQuery like this:

$('#inputDatabaseName').on('input',function(e){    alert('Changed!')});

In pure JavaScript:

document.querySelector("input").addEventListener("change",function () {  alert("Input Changed");})

Or like this:

<input id="inputDatabaseName" onchange="youFunction();"onkeyup="this.onchange();" onpaste="this.onchange();" oninput="this.onchange();"/>


try keyup instead of change.

<script type="text/javascript">   $(document).ready(function () {       $('#inputDatabaseName').keyup(function () { alert('test'); });   });</script>

Here's the official jQuery documentation for .keyup().


Each answer is missing some points, so here is my solution:

$("#input").on("input", function(e) {  var input = $(this);  var val = input.val();  if (input.data("lastval") != val) {    input.data("lastval", val);    //your change action goes here     console.log(val);  }});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><input type="text" id="input"><p>Try to drag the letters and copy paste</p>