Created
August 1, 2013 08:34
-
-
Save egulhan/7f19a5b7367031472db5 to your computer and use it in GitHub Desktop.
Check a IP is valid or not.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var | |
ip=attr.val(), | |
ipPatt=/^([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d?|2[0-4]\d|25[0-5])$/; | |
// If invalid ip | |
if(!ipPatt.test(ip)) | |
alert('invalid ip'); | |
else | |
alert('valid ip'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment