title: Javascript - Return value if field is left blank
body: <p>I'm new to coding and I am having trouble returning a value if a field on a form is left blank. The field requires the data input to be between 1 and 10000, if the field is left blank I want -1 as the value. Here is my attempt that is not working....</p>
  
  <pre><code>function validatePosition() {
    var position = document.getElementById('Position').value;
    var positionConditions = /^[0-9]+$/;
    if (position.match(positionConditions) &amp;&amp; (position &lt;= 10000 &amp;&amp; position &gt;= 1)) {
      return "";
    } else if (position.value.length == 0) {
      position.value = -1;
    } else {
      return "Error";
    }
  }
  </code></pre>