Posted By


plasticbottle on 03/14/18

Tagged


Statistics


Viewed 854 times
Favorited by 0 user(s)

JavaScript IP validation


/ Published in: JavaScript
Save to your folder(s)

JavaScript regex for validating IP addresses, has been tested!


Copy this code and paste it in your HTML
  1. 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;}

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.