Js 正则表达式验证IP地址

1.验证方法

function isValidIP(ip) {
    var reg = /^(\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])$/
    return reg.test(ip);
} 

2.判断

isValidIP(NewIP) == false

 

 

posted @ 2017-07-27 17:08  XinYiBuFang  阅读(45892)  评论(1编辑  收藏  举报