summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-base/htdocs
diff options
context:
space:
mode:
authorDaniel Dickinson <openwrt@daniel.thecshore.com>2015-12-14 22:51:29 -0500
committerDaniel Dickinson <openwrt@daniel.thecshore.com>2015-12-15 20:41:01 -0500
commitc481f3f34325b9c1cf817b16a567a6b10fdd1f2e (patch)
tree5fe6f363c0ff7544a25bdbb21c17873ade06d272 /modules/luci-base/htdocs
parentbbcfad7953489ed87336e3a1981c9cb19e390cdb (diff)
validation: Add option ipv4only option to host and hostport datatypes
Some applications only support ipv4 so add ipv4only option to host and hostport datatypes so that for thos applications that when an IP address is specified only and ipv4 ip address gets accepted.
Diffstat (limited to 'modules/luci-base/htdocs')
-rw-r--r--modules/luci-base/htdocs/luci-static/resources/cbi.js9
1 files changed, 5 insertions, 4 deletions
diff --git a/modules/luci-base/htdocs/luci-static/resources/cbi.js b/modules/luci-base/htdocs/luci-static/resources/cbi.js
index 19a1edec4..1c4123bda 100644
--- a/modules/luci-base/htdocs/luci-static/resources/cbi.js
+++ b/modules/luci-base/htdocs/luci-static/resources/cbi.js
@@ -139,10 +139,11 @@ var cbi_validators = {
return (this.match(/^([a-fA-F0-9]{2}:){5}[a-fA-F0-9]{2}$/) != null);
},
- 'host': function()
+ 'host': function(ipv4only)
{
return cbi_validators.hostname.apply(this) ||
- cbi_validators.ipaddr.apply(this);
+ ((ipv4only != 1) && cbi_validators.ipaddr.apply(this)) ||
+ ((ipv4only == 1) && cb_validators.ip4addr.apply(this));
},
'hostname': function()
@@ -161,12 +162,12 @@ var cbi_validators = {
cbi_validators.host.apply(this);
},
- 'hostport': function()
+ 'hostport': function(ipv4only)
{
var hp = this.split(/:/);
if (hp.length == 2)
- return (cbi_validators.host.apply(hp[0]) &&
+ return (cbi_validators.host.apply(hp[0], ipv4only) &&
cbi_validators.port.apply(hp[1]));
return false;