So my JS skills are way to low, but I tried this, but it doesn't seem to work:

$.validator.addMethod("ipv46cidr", function(value, element) {
    if (!$.validator.methods.ipv4cidr.call(this, value, element) | 
!$.validator.methods.ipv6cidr.call(this, value, element))
        return false;

    return true;
}, "The specified IPv4/IPv6 CIDR is invalid.");

What am I missing here?

Wido

> Op 23 oktober 2016 om 9:37 schreef Rohit Yadav <rohit.ya...@shapeblue.com>:
> 
> 
> Hi Wido,
> 
> 
> Yes, you can add a new validator that can validator that the provided address 
> is either ipv4 or ipv6, here:
> 
> https://github.com/apache/cloudstack/blob/master/ui/scripts/sharedFunctions.js#L2327
> 
> 
> Give the validator any appropriate name, and use it in the network.js code 
> replacing the currently defined validator with yours.
> 
> 
> Regards.
> 
> ________________________________
> From: Wido den Hollander <w...@widodh.nl>
> Sent: 21 October 2016 17:33:29
> To: dev@cloudstack.apache.org
> Subject: Question about JavaScript validators in UI
> 
> Hi,
> 
> While working on the IPv6 for Basic Networking I'm at the stage of the 
> Security Groups.
> 
> When entering a CIDR in the UI which is not IPv4 (eg ::/0) it will show: 'The 
> specified IPv4 CIDR is invalid.'
> 
> That's true, so looking in network.js I see this piece of code:
> 
> 'cidr': {
>   edit: true,
>   label: 'label.cidr',
>   isHidden: true,
>   validation: {
>     ipv4cidr: true
>   }
>  },
> 
> There is a ipv6cidr validation method as well. How can I modify the 
> JavaScript in such a way that either a valid IPv4 OR IPv6 CIDR has to be 
> entered?
> 
> My JavaScript skills are rather low.
> 
> Thanks!
> 
> Wido
> 
> rohit.ya...@shapeblue.com 
> www.shapeblue.com
> 53 Chandos Place, Covent Garden, London  WC2N 4HSUK
> @shapeblue
>   
>  
>

Reply via email to