title: JavaScript, get the value of input field on entry
body: <p>I have a HTML page with an input field that the user enters a value into. The HTML code looks like this:</p>
  <pre class="lang-html prettyprint-override"><code>&lt;div class=&quot;d-flex mg-b-0 mb-3&quot; id=&quot;cbWrapper2&quot;&gt;
      &lt;input type=&quot;number&quot; name=&quot;message_average&quot; class=&quot;form-control&quot; id=&quot;id_message_average&quot;&gt;
  &lt;/div&gt;
  </code></pre>
  <p>I'm trying to use JavaScript to get the value entered by the user so that I can then compare it against another value and write out the result, but I'm not sure how I collect the initial value being entered. What I have so far:</p>
  <pre class="lang-js prettyprint-override"><code>&lt;script&gt;
    var value = document.getElementById(&quot;id_message_average&quot;).value;
    console.log(value);
  &lt;/script&gt;
  </code></pre>
  <p>I'm just trying to write the value out for now so that I can tell it's working. Do I need to put it into some kind of event listener maybe when the user clicks onto another input field, or is there a way to have the script fire when a character is added?</p>