Explorar el Código

fleat: update customersave

igb hace 6 días
padre
commit
413328381a
Se han modificado 2 ficheros con 28 adiciones y 6 borrados
  1. 15 4
      customerAdd.php
  2. 13 2
      customerEdit.php

+ 15 - 4
customerAdd.php

@@ -79,7 +79,7 @@ checkLogin();
                         <option value="email" ${(methodCounts.email || 0) >= 3 ? 'disabled' : ''}>邮箱</option>
                         <option value="linkedin" ${(methodCounts.linkedin || 0) >= 3 ? 'disabled' : ''}>领英</option>
                         <option value="facebook" ${(methodCounts.facebook || 0) >= 3 ? 'disabled' : ''}>Facebook</option>
-                        <option value="alibaba" ${(methodCounts.alibaba || 0) >= 3 ? 'disabled' : ''}>阿里巴巴/阿里旺旺</option>
+                        <option value="alibaba" ${(methodCounts.alibaba || 0) >= 3 ? 'disabled' : ''}>阿里巴巴</option>
                     </select>
                     <input type="text" class="txt1 method-input" style="width:60%;" placeholder="请选择联系方式类型">
                     <button type="button" class="remove-method-btn">删除</button>
@@ -205,7 +205,7 @@ checkLogin();
                 placeholder = "Whatsapp 格式必须为:区号+号码 如:+86 15012345678";
                 break;
             case "email":
-                placeholder = "邮";
+                placeholder = "邮箱格式必须正确,如: example@domain.com";
                 break;
             case "linkedin":
                 placeholder = "领英链接";
@@ -214,7 +214,7 @@ checkLogin();
                 placeholder = "Facebook";
                 break;
             case "alibaba":
-                placeholder = "阿里巴巴/阿里旺旺";
+                placeholder = "阿里巴巴";
                 break;
             default:
                 placeholder = "请选择联系方式类型";
@@ -238,7 +238,7 @@ checkLogin();
         }
         
         if (clientCountry == 0 || !clientCountry) {
-            alert("地区/国家不能为空?");
+            alert("这是哪个国家的客户?");
             $("#cs_country").focus();
             return false;
         }
@@ -253,6 +253,7 @@ checkLogin();
         var hasContactMethod = false;
         var allContactsValid = true;
         var phoneRegex = /^\+\d{1,4}\s\d{5,}$/; // Regex to validate phone format: +[country code] [number]
+        var emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/; // Regex to validate email format
         
         $('.contact-form').each(function(contactIndex) {
             var $form = $(this);
@@ -285,6 +286,16 @@ checkLogin();
                         return false;
                     }
                 }
+                
+                // Validate email format
+                if (methodType === 'email' && methodValue) {
+                    if (!emailRegex.test(methodValue)) {
+                        alert("邮箱格式不正确,请输入有效的邮箱地址");
+                        $(this).find('input.method-input').focus();
+                        allContactsValid = false;
+                        return false;
+                    }
+                }
             });
             
             // If contact has a name but no methods, or has methods but no name

+ 13 - 2
customerEdit.php

@@ -274,7 +274,7 @@ if (!empty($id) && is_numeric($id)) {
                 placeholder = "Whatsapp 格式必须为:区号+号码 如:+86 15012345678";
                 break;
             case "email":
-                placeholder = "邮";
+                placeholder = "邮箱格式必须正确,如: example@domain.com";
                 break;
             case "linkedin":
                 placeholder = "领英链接";
@@ -322,6 +322,7 @@ if (!empty($id) && is_numeric($id)) {
         var hasContactMethod = false;
         var allContactsValid = true;
         var phoneRegex = /^\+\d{1,4}\s\d{5,}$/; // Regex to validate phone format: +[country code] [number]
+        var emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/; // Regex to validate email format
         
         $('.contact-form').each(function(contactIndex) {
             var $form = $(this);
@@ -354,6 +355,16 @@ if (!empty($id) && is_numeric($id)) {
                         return false;
                     }
                 }
+                
+                // Validate email format
+                if (methodType === 'email' && methodValue) {
+                    if (!emailRegex.test(methodValue)) {
+                        alert("邮箱格式不正确,请输入有效的邮箱地址");
+                        $(this).find('input.method-input').focus();
+                        allContactsValid = false;
+                        return false;
+                    }
+                }
             });
             
             // If contact has a name but no methods, or has methods but no name
@@ -518,7 +529,7 @@ if (!empty($id) && is_numeric($id)) {
                     <td><input type="text" id="cs_company" name="cs_company" value="<?= htmlspecialcharsFix($customer['cs_company']) ?>" class="txt1" /></td>
                 </tr>
                 <tr>
-                    <th width="8%">地区</th>
+                    <th width="8%">地区/国家</th>
                     <td>
                         <div class="layui-input-inline">
                             <div class="layui-form-select ySearchSelect y1">