From 63a75c6ea924120273f27a297fae4978ab81d83f Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Tue, 14 Feb 2012 15:16:53 +0000 Subject: [PATCH] libs/web: implement new phone digit datatype, useful for VoIP related config screens --- libs/web/htdocs/luci-static/resources/cbi.js | 4 ++++ libs/web/luasrc/cbi/datatypes.lua | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/libs/web/htdocs/luci-static/resources/cbi.js b/libs/web/htdocs/luci-static/resources/cbi.js index 7171574ef..8ced4419a 100644 --- a/libs/web/htdocs/luci-static/resources/cbi.js +++ b/libs/web/htdocs/luci-static/resources/cbi.js @@ -269,6 +269,10 @@ var cbi_validators = { return false; return true; + }, + 'phonedigit': function() + { + return (this.match(/^[0-9\*#]+$/) != null); } }; diff --git a/libs/web/luasrc/cbi/datatypes.lua b/libs/web/luasrc/cbi/datatypes.lua index 71f4a2a56..87019c225 100644 --- a/libs/web/luasrc/cbi/datatypes.lua +++ b/libs/web/luasrc/cbi/datatypes.lua @@ -305,3 +305,7 @@ function max(val, max) return false end + +function ponedigit(val) + return (val:match("^[0-9\*#]+$") ~= nil) +end -- 2.25.1