Dear Lazyweb,

I’m not the top javascript hacker of the pops, but somehow I need an input validation for CIDR addresses.

Preferences:

  1. JQuery
  2. JQuery Validation
  3. an address like this: 192.168.0.0/24

I came up with this snippet:

jQuery.validator.addMethod("cidraddr",function(value,element){console.log(value);return this.optional(element)||/^\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\/\d{1,2}\b$/.test(value);},jQuery.validator.format("Please enter a valid CIDR Address!"));

But it’s not enough. If you have a good CIDR regexp, please add it here via comments, or if I didn’t understand the adding of a jquery validator, please add a better one :) 

Use the usual communication channels to get in touch with me.

TIA