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

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