Просмотр исходного кода

new check_configure_kerio_buisness_mail.tpl

andre 6 месяцев назад
Родитель
Сommit
4db9104fe7
1 измененных файлов с 25 добавлено и 7 удалено
  1. 25 7
      check_configure_kerio_buisness_mail.tpl

+ 25 - 7
check_configure_kerio_buisness_mail.tpl

@@ -4,6 +4,10 @@
 </style>
 
 <script>
+    function is_domain(str) {
+        const regexp = /^[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,6}$/i;
+        return regexp.test(str);
+    }
     function checkInput (domain, pid) {
         var xhttp = new XMLHttpRequest();
         var success = false;
@@ -47,17 +51,31 @@
         $(customFields[0]).val(''); // domain
         $(checkBox[0]).removeClass('checked'); // checkbox
         $(customFields[0]).blur(function () {
-            checkInput( $(customFields[0]).val().trim(), {$productinfo['pid']});
+            if (is_domain($(customFields[0]).val().trim())) {
+                setTimeout(function () {
+                    checkInput( $(customFields[0]).val().trim(), {$productinfo['pid']});
+                }, 1);
+            } else {
+                    console.log('onBlur');
+            }
         });
         $(customFields[0]).on('input', function () {
-            setTimeout(function () {
-                checkInput( $(customFields[0]).val().trim(), {$productinfo['pid']});
-            }, 1);
+            if (is_domain($(customFields[0]).val().trim())) {
+                setTimeout(function () {
+                    checkInput( $(customFields[0]).val().trim(), {$productinfo['pid']});
+                }, 1);
+            } else {
+                    console.log('onInput');
+            }
         });
         $(checkBoxHelper[0]).click(function () {
-            setTimeout(function () {
-                checkInput( $(customFields[0]).val().trim(), {$productinfo['pid']});
-            }, 1);
+            if (is_domain($(customFields[0]).val().trim())) {
+                setTimeout(function () {
+                    checkInput( $(customFields[0]).val().trim(), {$productinfo['pid']});
+                }, 1);
+            } else {
+                    console.log('onClick');
+            }
         });
     });
 </script>