title: How to check if a string is a positive integer not starting with 0 using regex?
body: <p>After much research I have yet to discover a regular expression that satisfies all of these IF conditions. The code works great but I think it can be streamlined with RegEx.</p>
  
  <p>The goal: Return true on positive integers ranging from 1 through 9 NOT starting with a zero. Return false for every single other value.</p>
  
  <p>Take a look.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>// Validation functions
  
  
  function hasPeriod(s) {
    // Return true or false.
    // True if a period is entered at any point in time.
    return s.indexOf('.') &gt; -1;
  }
  // See more... http://2ality.com/2014/05/is-integer.html
  function isInteger(s) {
    // Return true or false.
    // True if the remainder of dividing it by 1 is 0.
    return s % 1 === 0;
  }
  
  
  
  // Bind keyup event to prep_work_item_input.
  $('#input1').on('keyup', function (e) {
  
    // TRIM text input value on declaration...
    // May contain spaces...
    var input_value = $(this).val().trim();
  
    // Refresh text input after Trim!
    // Does not contain spaces
    $(this).val(input_value);
  
    // If text input is EMPTY after Trim...
    if (input_value.length == 0) {
  
      // Stop at this if and dont proceed.
      return false;
  
    } 
  
    // If a PERIOD is typed into text input at any point in time...
    if (hasPeriod(input_value)) {
  
      // Clear input
      $(this).val('');
  
      // Stop at this if and dont proceed.
      return false;
  
    }
  
    // If text input value is NOT an INTEGER...
    if (!isInteger(input_value)) {
  
      // Clear input
      $(this).val('');
  
      // Stop at this if and dont proceed.
      return false;
    }
  
    // If text input value IS an INTEGER but EQUAL to 0...
    if (input_value == 0) {
  
      // Clear input
      $(this).val('');
  
      // Stop at this if and dont proceed.
      return false;
    }
  
    // If text input value IS an INTEGER and also GREATER than 0...
    if (input_value &gt; 0) {
  
      // If we have made this far... 
      // we probably have a real integer that is not zero.
  
      // We can finally begin to calculate
  
      input_value = parseInt(input_value);
  
      // random cost multiplier for this example
      var cost = parseFloat('0.78');
  
      // calculate subtotal...
      cost = input_value * cost;
  
      // Set prep_work_item_subtotal...        
      console.log(input_value + ' ' + 'SF' + ' / ' + ' $' + cost.toFixed(2));
  
    }
  
  });</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"&gt;&lt;/script&gt;
  
  &lt;label&gt;Enter value below:&lt;/label&gt;
  &lt;br&gt;
  &lt;input type="text" id="input1" placeholder="enter value"&gt;</code></pre>
  </div>
  </div>
  </p>