]> www.vanbest.org Git - motioneye-debian/commitdiff
camera names and email addresses are now validated
authorCalin Crisan <ccrisan@gmail.com>
Sun, 22 Feb 2015 18:54:41 +0000 (20:54 +0200)
committerCalin Crisan <ccrisan@gmail.com>
Sun, 22 Feb 2015 19:02:20 +0000 (21:02 +0200)
static/js/main.js

index 43c8979a9bdf0997db0ccc8581f914314c91bcfc..4cce2c39aeaf96489316147050400a679b8c66ce 100644 (file)
@@ -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]'));