luci-app-nlbwmon: validate date input
authorJo-Philipp Wich <jo@mein.io>
Fri, 13 Jan 2023 20:26:52 +0000 (21:26 +0100)
committerJo-Philipp Wich <jo@mein.io>
Fri, 13 Jan 2023 20:26:52 +0000 (21:26 +0100)
Fixes: #6188
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
applications/luci-app-nlbwmon/htdocs/luci-static/resources/view/nlbw/config.js

index 3f0a4c969f83d5376919cebc524d77aa501221b2..bdebf296eabebdd9e4b0ea8084070e2426915562 100644 (file)
@@ -102,6 +102,9 @@ return view.extend({
 
                        return m ? m[1] : null;
                };
+               o.validate = function(section_id, value) {
+                       return /^[0-9]{4}-[0-9]{2}-[0-9]{2}$/.exec(value) ? true : _('Require a valid date in the form "YYYY-MM-DD"');
+               };
                o.write = writePeriod;
                o.depends('_period', 'absolute');