js 检测ip程序

作者:袖梨 2022-07-02
提示:您可以先修改部分代码再运行
js 检测ip程序 function checkIP() { var ipArray,ip,j; ip = document.ipform.ip.value; if(/[A-Za-z_-]/.test(ip)){ if(!/^([w-]+.)+((com)|(net)|(org)|(gov.cn)|(info)|(cc)|(com.cn)|(net.cn)|(org.cn)|(name)|(biz)|(tv)|(cn)|(mobi)|(name)|(sh)|(ac)|(io)|(tw)|(com.tw)|(hk)|(com.hk)|(ws)|(travel)|(us)|(tm)|(la)|(me.uk)|(org.uk)|(ltd.uk)|(plc.uk)|(in)|(eu)|(it)|(jp))$/.test(ip)){ alert("不是正确的域名"); document.ipform.ip.focus(); return false; } } else{ ipArray = ip.split("."); j = ipArray.length if(j!=4) { alert("不是正确的IP"); document.ipform.ip.focus(); return false; } for(var i=0;i<4;i++) { if(ipArray[i].length==0 || ipArray[i]>255) { alert("不是正确的IP"); document.ipform.ip.focus(); return false; } } } }
提示:您可以先修改部分代码再运行

相关文章

精彩推荐