Advertisement
bueddl

Untitled

Jul 29th, 2015
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     var str = "127.0.0.1";
  2.     var matches = str.match(/^(\d+)\.(\d+)\.(\d+)\.(\d+)$/);
  3.     if (matches.length > 0) {
  4.         var a = parseInt(matches[1]);
  5.         var b = parseInt(matches[2]);
  6.         var c = parseInt(matches[3]);
  7.         var d = parseInt(matches[4]);
  8.         if (a >= 1 && a <= 255 &&
  9.             b >= 0 && b <= 255 &&
  10.             c >= 0 && c <= 255 &&
  11.             d >= 0 && d <= 255) {
  12.             alert('IP');
  13.         }
  14.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement