JS regular expression validation port range (0-65535)

Time:2020-7-28

Verification of port validity of IP address by JavaScript regular expression

if (!(/^[1-9]\d*$/.test(port) && 1 <= 1 * port && 1 * port <= 65535)){
    return false
}

Prompt copy:

Your port does not match the range: 0-65535