/ Published in: JavaScript

JavaScript regex for validating IP addresses, has been tested!
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function isValidIP(ip_str) {if(/^(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]?)$/.test(ip_str)) {return true;} else return false;}
Comments
