Browse Source

手機格式功能

jeter20131220 3 năm trước cách đây
mục cha
commit
697a08c106
3 tập tin đã thay đổi với 71 bổ sung31 xóa
  1. 69 29
      desktop11/goto.js
  2. 1 1
      desktop11/index.html
  3. 1 1
      desktop11/style.scss

+ 69 - 29
desktop11/goto.js

@@ -126,37 +126,77 @@ $(".contact-form1").submit(function (e) {
     }
 
   });
+  $(document).ready(function () {
+
+    //E-MAIL格式檢查
+
+    $("body").on("change", "#phone", function () {
+
+      $Phonechecking = IsPhone($("#phone").val());
+
+
+      if ($Phonechecking == false) {
+
+        alert("請填寫正確的手機格式");
+
+        // $("#email").blur(); //離開焦點
+
+      }
+
+    })
+
+    function IsPhone(phone) {
+
+      var regex = /^[0-9]+$/;
+
+      if (!regex.test(phone)) {
+
+        return false;
+
+      } else {
+
+        return true;
+
+      }
+
+    }
+
+  });
+
   
-$.ajax({
-  type: 'POST',
-  url: 'http://cal.ptt.cx/deco_request_detail',
-  data: jsonString,
-  dataType: 'json',
-  success: function (data) {
-    console.log('送出成功: ' + data);
-    if (data == 0) {
-      alert("送出成功");
-    } else if (data == 1) {
-      alert("此email已填過表單");
-    } else if (data == 2) {
-      alert("此phone已填過表單");
-    } else if (data == 3) {
-      alert("此email、phone已填過表單");
+
+
+
+  $.ajax({
+    type: 'POST',
+    url: 'http://cal.ptt.cx/deco_request_detail',
+    data: jsonString,
+    dataType: 'json',
+    success: function (data) {
+      console.log('送出成功: ' + data);
+      if (data == 0) {
+        alert("送出成功");
+      } else if (data == 1) {
+        alert("此email已填過表單");
+      } else if (data == 2) {
+        alert("此phone已填過表單");
+      } else if (data == 3) {
+        alert("此email、phone已填過表單");
+      }
+    },
+    beforeSend: function () {
+      console.log('beforeSend');
+    },
+    complete: function () {
+      console.log('complete');
+    },
+    error: function (jqXHR, textStatus, errorThrown) {
+      console.log(JSON.stringify(jqXHR));
+      console.log("AJAX errr: " + textStatus + ' : ' + errorThrown);
+      console.log('送出失敗: ' + jqXHR.responseText);
     }
-  },
-  beforeSend: function () {
-    console.log('beforeSend');
-  },
-  complete: function () {
-    console.log('complete');
-  },
-  error: function (jqXHR, textStatus, errorThrown) {
-    console.log(JSON.stringify(jqXHR));
-    console.log("AJAX errr: " + textStatus + ' : ' + errorThrown);
-    console.log('送出失敗: ' + jqXHR.responseText);
-  }
-});
-return false;
+  });
+  return false;
 });
 
 

+ 1 - 1
desktop11/index.html

@@ -254,7 +254,7 @@
             </div>
             <!-- <hr> -->
             <div class="contact-text">
-                <div class="text-p">請撥打全台付費專線<span style="opacity: 0;">11</span><span id="phone"
+                <div class="text-p">請撥打全台付費專線<span style="opacity: 0;">11</span><span id="phone1"
                         style="color: #ee751b; font-weight:900;"> 0800-336-086</span></div>
                 <div class="text-p">或填寫以下資料,專人將盡速與您聯繫</div>
             </div>

+ 1 - 1
desktop11/style.scss

@@ -580,7 +580,7 @@ body {
         position: relative;
         width: 75vw;
         margin: 0 auto;
-        #phone {
+        #phone1 {
             position: absolute;
             left: 500px;
         }