X-Git-Url: http://git.archive.openwrt.org/?a=blobdiff_plain;f=modules%2Fluci-base%2Fhtdocs%2Fluci-static%2Fresources%2Fcbi.js;h=4b7227f1a4e959c225dfa0fecac9e78a64d58c19;hb=6318f67fd46450b501879d9cf36c023fab7824d3;hp=8a3cb6fca7c3c963a5d3c60f6e44ceeea2babde5;hpb=63155e99325d2f7b57eee99496648e7a3cf6c14b;p=project%2Fluci.git diff --git a/modules/luci-base/htdocs/luci-static/resources/cbi.js b/modules/luci-base/htdocs/luci-static/resources/cbi.js index 8a3cb6fca..4b7227f1a 100644 --- a/modules/luci-base/htdocs/luci-static/resources/cbi.js +++ b/modules/luci-base/htdocs/luci-static/resources/cbi.js @@ -322,6 +322,47 @@ var cbi_validators = { 'phonedigit': function() { return (this.match(/^[0-9\*#!\.]+$/) != null); + }, + 'timehhmmss': function() + { + return (this.match(/^[0-6][0-9]:[0-6][0-9]:[0-6][0-9]$/) != null); + }, + 'dateyyyymmdd': function() + { + if (this == null) { + return false; + } + if (this.match(/^(\d\d\d\d)-(\d\d)-(\d\d)/)) { + var year = RegExp.$1; + var month = RegExp.$2; + var day = RegExp.$2 + + var days_in_month = [ 31, 28, 31, 30, 31, 30, 31, 31, 30 , 31, 30, 31 ]; + function is_leap_year(year) { + return ((year % 4) == 0) && ((year % 100) != 0) || ((year % 400) == 0); + } + function get_days_in_month(month, year) { + if ((month == 2) && is_leap_year(year)) { + return 29; + } else { + return days_in_month[month]; + } + } + /* Firewall rules in the past don't make sense */ + if (year < 2015) { + return false; + } + if ((month <= 0) || (month > 12)) { + return false; + } + if ((day <= 0) || (day > get_days_in_month(month, year))) { + return false; + } + return true; + + } else { + return false; + } } };