title: Custom JS logic to validate IP ranges does not work as intended
body: <p>I need to create some logic that allows for validation of a specified IP range. Not a single IP address but two addresses that make up a single range.</p>
  
  <p>I thought this would be somewhat simple so I devised some JS code that splits up the two input strings represented the ranges using a <code>.</code> delimiter and then compared each number in the first range with the equivalent number in the second range. If the start number is greater than the end number then the range would be invalid.</p>
  
  <p>This works, to a degree. However it's not completely accurate as I'm getting pairs such as <code>127.0.0.3 / 128.0.0.1</code> which return false when in reality this pair of IP addresses is a valid range (ignoring the technicalities with using 127 etc.) </p>
  
  <p>I'm not sure how exactly to check for a valid IP range, using Google doesn't seem to return any information on how to validate an IP range either.</p>
  
  <p>How can I change my code around so that all invalid ranges are included and all invalid are excluded?</p>
  
  <pre><code>getIpRangeValidStates() : boolean[] {
      console.log("getIdRangeValidStates");
      let validStates = [];
  
      for(let i = 0; i &lt; this.ipRangeFormArray.length; i++){
        let currentFormGroup = this.ipRangeFormArray.controls[i];
        let startRangeElements = (currentFormGroup.get('startRange').value as string).split(".");
        let endRangeElements = (currentFormGroup.get('endRange').value as string).split(".");
  
        let rangeValid = true;
        for(let j = 0; j &lt; 4; j++) {
          let startRangeAsInt = parseInt(startRangeElements[j]);
          let endRangeAsInt = parseInt(endRangeElements[j]);
          console.log(startRangeAsInt, " : ", endRangeAsInt);
  
          if(isNaN(startRangeAsInt) || isNaN(endRangeAsInt))
          {
            console.log("NaN, invalid");
            rangeValid = false;
          }
          else
          {
            if(startRangeAsInt &gt; endRangeAsInt) {
              console.log(startRangeAsInt, " &gt; ", endRangeAsInt, "- invalid")
              rangeValid = false;
            }
          }
        }
  
        rangeValid === false ? validStates.push(false) : validStates.push(true); 
      }
      console.log("Range states: ", validStates);
      return validStates;
    }
  </code></pre>