Skip to content

Commit f0a2bf9

Browse files
Fix issue with verification of ipv4/ipv6 address. (#3162)
1 parent 58466c8 commit f0a2bf9

2 files changed

Lines changed: 22 additions & 5 deletions

File tree

ui/scripts/network.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1782,7 +1782,7 @@
17821782
label: 'label.ip.address',
17831783
validation: {
17841784
required: false,
1785-
ipv46address: true
1785+
ipv4AndIpv6AddressValidator: true
17861786
}
17871787
}
17881788
}

ui/scripts/sharedFunctions.js

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ var addGuestNetworkDialog = {
676676
label: 'label.ipv6.gateway',
677677
docID: 'helpGuestNetworkZoneGateway',
678678
validation: {
679-
ipv6: true
679+
ipv6CustomJqueryValidator: true
680680
}
681681
},
682682
ip6cidr: {
@@ -689,14 +689,14 @@ var addGuestNetworkDialog = {
689689
label: 'label.ipv6.start.ip',
690690
docID: 'helpGuestNetworkZoneStartIP',
691691
validation: {
692-
ipv6: true
692+
ipv6CustomJqueryValidator: true
693693
}
694694
},
695695
endipv6: {
696696
label: 'label.ipv6.end.ip',
697697
docID: 'helpGuestNetworkZoneEndIP',
698698
validation: {
699-
ipv6: true
699+
ipv6CustomJqueryValidator: true
700700
}
701701
},
702702
//IPv6 (end)
@@ -2582,7 +2582,7 @@ $.validator.addMethod("ipv6cidr", function(value, element) {
25822582
return false;
25832583
}
25842584

2585-
if (!$.validator.methods.ipv6.call(this, parts[0], element))
2585+
if (!$.validator.methods.ipv6CustomJqueryValidator.call(this, parts[0], element))
25862586
return false;
25872587

25882588
if (parts[1] != Number(parts[1]).toString()) //making sure that "", " ", "00", "0 ","2 ", etc. will not pass
@@ -2625,6 +2625,23 @@ $.validator.addMethod("ipv46cidr", function(value, element) {
26252625
return false;
26262626
}, "The specified IPv4/IPv6 CIDR is invalid.");
26272627

2628+
jQuery.validator.addMethod("ipv4AndIpv6AddressValidator", function(value, element) {
2629+
if (this.optional(element) && value.length == 0) {
2630+
return true;
2631+
}
2632+
if (jQuery.validator.methods.ipv4.call(this, value, element) || jQuery.validator.methods.ipv6CustomJqueryValidator.call(this, value, element)) {
2633+
return true;
2634+
}
2635+
return false;
2636+
}, "The specified IPv4/IPv6 address is invalid.");
2637+
2638+
jQuery.validator.addMethod("ipv6CustomJqueryValidator", function(value, element) {
2639+
if (value == '::'){
2640+
return true;
2641+
}
2642+
return jQuery.validator.methods.ipv6.call(this, value, element);
2643+
}, "The specified IPv6 address is invalid.");
2644+
26282645

26292646
$.validator.addMethod("allzonesonly", function(value, element){
26302647

0 commit comments

Comments
 (0)