Created
December 4, 2012 09:22
-
-
Save yannisxu/4202129 to your computer and use it in GitHub Desktop.
Javascript:IPRegular
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
obj="1.1.1.1" | |
//ip地址 | |
var exp=/^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/; | |
var reg = obj.match(exp); | |
if(reg==null) | |
{ | |
alert("IP地址不合法!"); | |
} | |
else | |
{ | |
alert("IP地址合法!"); | |
} | |
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment