Skip to content

Commit

Permalink
Merge pull request vitmalina#1694 from anselal/patch-1
Browse files Browse the repository at this point in the history
⭐ new(validation): Add IP Address Validation
  • Loading branch information
vitmalina authored Oct 23, 2017
2 parents 486079c + f351cc5 commit 37b61a6
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/w2utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ var w2utils = (function ($) {
isHex : isHex,
isAlphaNumeric : isAlphaNumeric,
isEmail : isEmail,
isIpAddress : isIpAddress,
isDate : isDate,
isTime : isTime,
isDateTime : isDateTime,
Expand Down Expand Up @@ -159,6 +160,14 @@ var w2utils = (function ($) {
var email = /^[a-zA-Z0-9._%-]+@[а-яА-Яa-zA-Z0-9.-]+\.[а-яА-Яa-zA-Z]+$/;
return email.test(val);
}

function isIpAddress (val) {
var re = new RegExp('^' +
'((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}' +
'(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)' +
'$');
return re.test(val);
}

function isDate (val, format, retDate) {
if (!val) return false;
Expand Down

0 comments on commit 37b61a6

Please sign in to comment.