Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var str = "127.0.0.1";
- var matches = str.match(/^(\d+)\.(\d+)\.(\d+)\.(\d+)$/);
- if (matches.length > 0) {
- var a = parseInt(matches[1]);
- var b = parseInt(matches[2]);
- var c = parseInt(matches[3]);
- var d = parseInt(matches[4]);
- if (a >= 1 && a <= 255 &&
- b >= 0 && b <= 255 &&
- c >= 0 && c <= 255 &&
- d >= 0 && d <= 255) {
- alert('IP');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement