js判断是否是合法的端口号

时间:2020-07-06 18:44:48   收藏:0   阅读:72
function isPort(port) {
    if (/^[1-9]\d*|0$/.test(port) && port * 1 >= 0 && port * 1 <= 65535){
        return true
    }
    return false;
}

 

原文:https://www.cnblogs.com/nihaorz/p/13256050.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!