summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-base/htdocs
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2015-12-02 11:13:18 +0100
committerJo-Philipp Wich <jow@openwrt.org>2015-12-02 11:13:39 +0100
commit9b30357454ea53a9f1d7e82d8f894db5f409de98 (patch)
tree75e5e42da3cb1ea29206c13e8f490f6dd0e04fe8 /modules/luci-base/htdocs
parentea9f25b63ee0d9a380cf74c65061c3977cad3b2f (diff)
luci-base: add hostport and ipaddrport validation types
Add two new types 'hostport' and 'ipaddrport' to validate strings in the form 'sub.example.org:1234' and '0.0.0.0:80'. The 'hostport' accepts hostnames or IP addresses followed by a colon and a port number while the 'ipaddrport' type accepts numeric IP addresses only, followed by a colon and a port. Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
Diffstat (limited to 'modules/luci-base/htdocs')
-rw-r--r--modules/luci-base/htdocs/luci-static/resources/cbi.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/modules/luci-base/htdocs/luci-static/resources/cbi.js b/modules/luci-base/htdocs/luci-static/resources/cbi.js
index 02c54ad3e..8a3cb6fca 100644
--- a/modules/luci-base/htdocs/luci-static/resources/cbi.js
+++ b/modules/luci-base/htdocs/luci-static/resources/cbi.js
@@ -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;