• Content count

  • Joined

  • Last visited

  • Days Won


rain13 last won the day on August 20 2014

rain13 had the most liked content!

Community Reputation

7 Neutral

About rain13

  • Rank
  1. Hi. How do I reliably detect input change? At first I tried on change but it didnt work. Now I try onkeypress but it also doesnt work. You always have to press key twice before button changes state. If the input is empty and button is disabled, you have to type either 2 digit number or work around hack is that you type in 1 digit number and then hit one of the arrow keys. The same is when next button is enabled and you delete the text from input. when delete all digits from the input, it will not disable next button until you have pressed something else. Could anyone explain why I always have to key press at least 2 times before it reacts? And how could I fix it so that it would immediately react when it changes? <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> <script> function valueChanged(){ var inputValue = $("#interval_size").val(); if (inputValue == "") { $("#generalization_next").prop("disabled", true); } else { $("#generalization_next").prop("disabled", false); } } </script> </head> <body> <input type="number" id="interval_size" onkeypress="valueChanged()"> <input id="generalization_next" type="button" value="Next" disabled="disabled"> </body> </html>