title: Capture HTML5 error input validation when set in javascript (shows a warn) or check validation before
body: <p>I am trying validate a data to set in an input. I want to use de <strong>Validation HTML5</strong>.</p>
  
  <p>For example, I want to check if "aaaa" is a <strong>valid data for an number input</strong>. I wanted use <code>willValidate</code> or <code>validity</code> but I can not set an invalid value, the console shows (Chrome):</p>
  
  <blockquote>
    <p>The specified value "aaaa" is not a valid number. The value must match to the following regular expression: -?(\d+|\d+.\d+|.\d+)([eE][-+]?\d+)?</p>
  </blockquote>
  
  <p>I have tried catch the error <strong>but it is not an Exception</strong>. I retrieve the input value and it is empty after the error.</p>
  
  <pre class="lang-js prettyprint-override"><code>var value = "aaaa";
  
  try {
      document.getElementById("input").value = value; // Shows a warn
  } catch(err) {
      console.log(err.message); // Nothing catching
  }
  
  console.log( document.getElementById("input").value ); // It is empty
  </code></pre>
  
  <p><strong><a href="https://jsfiddle.net/SnakeDrak/qhz6xuf2/1/" rel="nofollow">See DEMO.</a></strong></p>
  
  <p><strong>MORE EXPLAINED</strong>:</p>
  
  <p>I want to check if a value to setted is valid in the input type. I thought set the invalid value in the input and check willValidate or validity but the browser shows a warn and the input value is empty. The problem is that my frontend set the inputs values via javascript but the user pass the values. When an error occurs I need show the error to the user and not put only and input empty..</p>
  
  <p><strong>UPDATED</strong>:</p>
  
  <p>I know that the warn is not an Exception. I want know shows the error when set an invalid input value in any type.</p>