function checkIPAddress(ip) {
let regex = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
if (ip.match(regex)) {
console.log("Ok");
return true;
}
else {
console.log("Error");
return false;
}
}
checkIPAddress("240.135.156.123")
/*
run:
Ok
*/