title: JS Validation IP:Port
body: <p>I have a question, on how to validate IP:Port together.
  example:</p>
  
  <p>192.158.2.10:80 &lt;--Valid</p>
  
  <p>192.158.2.10 &lt;---Invalid </p>
  
  <p>So the port is a must, I found some IP validation(Regex) but to be combind with port no luck. I dont want to use a seperate input field for port.</p>
  
  <p>My Idea was to like so:</p>
  
  <pre><code>var str = '192.168.10.2:80';
  var substr = ':';
       if (str.indexOf(substr) !== -1){
           var pieces = str.split(':', 2);
           var ip    = pieces[0];
           var port  = pieces[1];
           //and here validate ip and port
       }else{
           console.log('the char '+substr+' is not there');
       }
  </code></pre>
  
  <p>Is this right way? or there more simple?</p>