(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; } }