求验证IP地址的JS代码。带注释。谢谢~~

JavaScript017

求验证IP地址的JS代码。带注释。谢谢~~,第1张

<SCRIPT language=JScript event=OnObjectReady(objObject,objAsyncContext) for=foo>

if(objObject.IPEnabled != null &&objObject.IPEnabled != "undefined" &&objObject.IPEnabled == true)

{

if(objObject.MACAddress != null &&objObject.MACAddress != "undefined")

MACAddr = objObject.MACAddress

if(objObject.IPEnabled &&objObject.IPAddress(0) != null &&objObject.IPAddress(0) != "undefined")

IPAddr = objObject.IPAddress(0)

if(objObject.DNSHostName != null &&objObject.DNSHostName != "undefined")

sDNSName = objObject.DNSHostName

}

</SCRIPT>

/^(\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])$/

function isvalidurl( chars ) {// chars = chars.replace(',',)//var re=/^([hh][tt]{2}[pp]://|[hh][tt]{2}[pp][ss]://)((((w+(-*w*)+).)+((com)|(net)|(edu)|(gov)|(org)|(biz)|(aero)|(coop)|(info)|(name)|(pro)|(museum))(.([a-z]{2}))?)|((w+(-*w*)+).(cn)))$/var re=/^([hh][tt]{2}[pp]://|[hh][tt]{2}[pp][ss]://)(s+.s+)$///var re=/^([hh][tt]{2}[pp]://|[hh][tt]{2}[pp][ss]://)(((((w+(-*w*)+).)+((com)|(net)|(edu)|(gov)|(org)|(biz)|(aero)|(coop)|(info)|(name)|(pro)|(me)|(cc)|(museum)|(cn)|(tv)|(hk))(.([a-z]{2}))?)|((w+(-*w*)+).(cn)))((/|?)s*)*)$/if (!isnull(chars)) {chars = jstrim(chars)if (chars.match(re) == null)return falseelse