From 88b2183e062a5aef166e37ff473e758a8115c1f9 Mon Sep 17 00:00:00 2001 From: edisonxiang Date: Mon, 30 Sep 2019 10:57:01 +0800 Subject: [PATCH] addajaxinvoke --- content/en/cla.md | 6 ++-- content/zh/cla.md | 6 ++-- themes/project/static/js/cla.js | 60 +++++++++++++++++++++++++++++---- 3 files changed, 60 insertions(+), 12 deletions(-) diff --git a/content/en/cla.md b/content/en/cla.md index ed03c4c..b768088 100644 --- a/content/en/cla.md +++ b/content/en/cla.md @@ -93,7 +93,7 @@ Please select one applicable statement from the following and fill in the blanks Fax: - + @@ -170,7 +170,7 @@ Please select one applicable statement from the following and fill in the blanks Fax: - + @@ -183,7 +183,7 @@ Please select one applicable statement from the following and fill in the blanks @@ -173,7 +173,7 @@ title = "签署CLA" 传真: @@ -186,7 +186,7 @@ title = "签署CLA"
- + Sign diff --git a/content/zh/cla.md b/content/zh/cla.md index a826ea7..32021f2 100644 --- a/content/zh/cla.md +++ b/content/zh/cla.md @@ -96,7 +96,7 @@ title = "签署CLA" 传真: - +
- +
- + 签署 diff --git a/themes/project/static/js/cla.js b/themes/project/static/js/cla.js index efc9d8c..405f276 100644 --- a/themes/project/static/js/cla.js +++ b/themes/project/static/js/cla.js @@ -59,7 +59,7 @@ function initClaPage() { var checkpass = true; $("input[type=text]", "#individual-table").each(function (i) { if ($(this).hasClass("require")) { - if ($(this).val() == "") { + if ($.trim($(this).val()) == "") { checkpass = false; return false; } @@ -74,7 +74,7 @@ function initClaPage() { } return false; } - var email = $('#individual-email').val(); + var email = $.trim($('#individual-email').val()); if (!regemail.test(email)) { if (lang == "zh-cn") { $('#tip-cla-label').html("邮箱格式不正确!"); @@ -83,7 +83,7 @@ function initClaPage() { } return false; } - var telephone = $('#individual-telephone').val(); + var telephone = $.trim($('#individual-telephone').val()); if ((!regphone.test(telephone)) && (!regmobile.test(telephone))) { if (lang == "zh-cn") { $('#tip-cla-label').html("电话格式不正确!"); @@ -97,7 +97,7 @@ function initClaPage() { var checkpass = true; $("input[type=text]", "#legalentity-table").each(function (i) { if ($(this).hasClass("require")) { - if ($(this).val() == "") { + if ($.trim($(this).val()) == "") { checkpass = false; return false; } @@ -112,7 +112,7 @@ function initClaPage() { } return false; } - var email = $('#legalentity-email').val(); + var email = $.trim($('#legalentity-email').val()); if (!regemail.test(email)) { if (lang == "zh-cn") { $('#tip-cla-label').html("邮箱格式不正确!"); @@ -121,16 +121,64 @@ function initClaPage() { } return false; } - var telephone = $('#legalentity-telephone').val(); + var telephone = $.trim($('#legalentity-telephone').val()); if ((!regphone.test(telephone)) && (!regmobile.test(telephone))) { if (lang == "zh-cn") { $('#tip-cla-label').html("电话格式不正确!"); } else { $('#tip-cla-label').html("Telephone format is incorrent!"); } + return false; } } + // build json + var posturl = $(this).attr("posturl"); + var jsonData = {}; + if (v == 0) { + // individual + jsonData = { + "type": v, + "name": $.trim($('#individual-name').val()), + "address": $.trim($('#individual-address').val()), + "date": $.trim($('#individual-date').val()), + "email": $.trim($('#individual-email').val()), + "telephone": $.trim($('#individual-telephone').val()), + "fax": $.trim($('#individual-fax').val()), + }; + } else { + // legalentity + jsonData = { + "type": v, + "name": $.trim($('#legalentity-name').val()), + // only for legalentity + "title": $.trim($('#legalentity-title').val()), + // only for legalentity + "corporation": $.trim($('#legalentity-corporation').val()), + "address": $.trim($('#legalentity-address').val()), + "date": $.trim($('#legalentity-date').val()), + "email": $.trim($('#legalentity-email').val()), + "telephone": $.trim($('#legalentity-telephone').val()), + "fax": $.trim($('#legalentity-fax').val()), + }; + } + + // send request + $.ajax({ + type: "POST", + url: posturl, + data: JSON.stringify(jsonData), + contentType: "application/json; charset=utf-8", + crossDomain: true, + datatype: "json", + success: function (data) { + alert(data); + }, + error: function () { + alert("请求失败"); + } + }); + return false; }); } -- GitLab