From e9e96a0b67385ab9ed50ea850da23abd2dbfe7dc Mon Sep 17 00:00:00 2001 From: Calin Crisan Date: Sun, 22 Feb 2015 20:54:41 +0200 Subject: [PATCH] camera names and email addresses are now validated --- static/js/main.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/static/js/main.js b/static/js/main.js index 43c8979..4cce2c3 100644 --- a/static/js/main.js +++ b/static/js/main.js @@ -490,6 +490,17 @@ function initUI() { makeTimeValidator($('input[type=text].time')); /* custom validators */ + makeCustomValidator($('#deviceNameEntry'), function (value) { + if (!value) { + return 'this field is required'; + } + + if (!value.toLowerCase().match(new RegExp('^[a-z0-9\-\_\+\ ]*$'))) { + return "special characters are not allowed in camera's name"; + } + + return true; + }, ''); makeCustomValidator($('#rootDirectoryEntry'), function (value) { if ($('#storageDeviceSelect').val() == 'custom-path' && String(value).trim() == '/') { return 'files cannot be created directly on the root of your system'; @@ -497,6 +508,13 @@ function initUI() { return true; }, ''); + makeCustomValidator($('#emailAddressesEntry'), function (value) { + if (!value.toLowerCase().match(new RegExp('^[a-z0-9\-\_\+\.\@\^\~\, ]+$'))) { + return 'enter a list of comma-separated valid email addresses'; + } + + return true; + }, ''); /* input value processors */ makeStrippedInput($('tr[strip=true] input[type=text]')); -- 2.39.5