luci-base: add hostport and ipaddrport validation types
[project/luci.git] / modules / luci-base / htdocs / luci-static / resources / cbi.js
index 02c54ad..8a3cb6f 100644 (file)
@@ -161,6 +161,28 @@ var cbi_validators = {
                        cbi_validators.host.apply(this);
        },
 
+       'hostport': function()
+       {
+               var hp = this.split(/:/);
+
+               if (hp.length == 2)
+                       return (cbi_validators.host.apply(hp[0]) &&
+                               cbi_validators.port.apply(hp[1]));
+
+               return false;
+       },
+
+       'ipaddrport': function()
+       {
+               var hp = this.split(/:/);
+
+               if (hp.length == 2)
+                       return (cbi_validators.ipaddr.apply(hp[0]) &&
+                               cbi_validators.port.apply(hp[1]));
+
+               return false;
+       },
+
        'wpakey': function()
        {
                var v = this;