I have a question, on how to validate IP:Port together. example:
192.158.2.10:80 <--Valid
192.158.2.10 <---Invalid
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.
My Idea was to like so:
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');
     }
Is this right way? or there more simple?
 
     
     
     
     
    