(function ($) { var promoter = promoter || {}; promoter.utils = (function () { var controller = "../promoter"; var pro = function () { $("#email").on("blur", function () { ValEmail("email"); }); $("#application").on("click", function () { var email = $("#email").val(); if (!ValEmail("email")) { return false; } var arr = $("#email").val().replace(";", ";").split(";"); var data = { 'email': arr }; $.ajax({ type: "post", url: "promoter/index", data: data, dataType: 'json', success: function (data) { if (data.state == "success") { alert("Hello"); } else { alert("Faile"); } } }); }); }; return { pro: pro }; }()); $(function () { promoter.utils.pro(); }) })(jQuery); function ValEmail(em) { if ($("#" + em).val() == "") { $("#confirmMsg").html("<font color='red'>請輸入審批人郵箱!</font>"); $("#" + em).focus(); return false; } else { var arr = $("#" + em).val().replace(";", ";").split(";"); for (var i = 0; i < arr.length; i++) { if (!arr[i].match(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/)) { $("#confirmMsg").html("<font color='red'>當前'" + arr[i] + "'郵箱格式不正確!請從新輸入!</font>"); $("#" + em).focus(); return false; } else { $("#confirmMsg").html(""); } } return true; } }