In my project, I am able to validate IP addresses like this:
function (value, element) {
var octet = '(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]|[0-9])';
var ip = '(?:' + octet + '\\.){3}' + octet;
var ipRE = new RegExp('^' + ip + '$');
return (ipRE.test(value));
}
Currently, it’s accepting single IPv4 version addressses. I want to accept multiple IPv4/IPv6 version format too.
Example:
'0:0:0:0:0:ffff:192.1.56.10,172.30.60.1,fe80:41b2:41b2:935c:b113:da1a'
I am using the jQuery.validator API to perform validation.
Please provide suggestions.
The following code that i have used to accept both IPv6 and Ipv4 versions in jquery.