|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- $(function () {
- // $(".header_root").load("./comm/header.html");
- $(".footer_root").load("./comm/footer.html");
- // nav传值显示下划线
- // $(".header_root").data("nav_info", 4);
- $(".err_account").hide();
- $(".err_phone").hide();
- $(".err_mailbox").hide();
- //姓名
- $("#account").blur(() => {
- let name = $("#account").val();
- if (!name) {
- $(".err_account").show();
- }
- });
- $("#account").focus(() => {
- $(".err_account").hide();
- });
- //联系电话
- $("#phone").blur(() => {
- let phone = $("#phone").val();
- if (!phone) {
- $(".err_phone").show();
- }
- });
- $("#phone").focus(() => {
- $(".err_phone").hide();
- });
- var mailboxf = true;
- //邮箱
- $("#mailbox").blur(() => {
- let mailbox = $("#mailbox").val();
- mailboxf = false;
- var filter =
- /^[\w\-\.]+@[a-z0-9]+(\-[a-z0-9]+)?(\.[a-z0-9]+(\-[a-z0-9]+)?)*\.[a-z]{2,4}$/i;
- let blnTest = filter.test(mailbox);
- if (mailbox && !blnTest) {
- $(".err_mailbox").show();
- mailboxf = true;
- }
- });
- $("#mailbox").focus(() => {
- $(".err_mailbox").hide();
- });
- $("#mailbox").bind("input propertychange change", function (event) {
- let mailbox = $("#mailbox").val();
- mailboxf = false;
- var filter =
- /^[\w\-\.]+@[a-z0-9]+(\-[a-z0-9]+)?(\.[a-z0-9]+(\-[a-z0-9]+)?)*\.[a-z]{2,4}$/i;
- let blnTest = filter.test(mailbox);
- if (mailbox && !blnTest) {
- $(".err_mailbox").show();
- mailboxf = true;
- } else {
- $(".err_mailbox").hide();
- }
- });
- //提交
- var Loading = false;
-
- $(".btn").click(() => {
- if (Loading) {
- return;
- }
- let name = $("#account").val();
- if (!name) {
- $(".err_account").show();
- return;
- }
- let phone = $("#phone").val();
- if (!phone) {
- $(".err_phone").show();
- return;
- }
- if (mailboxf) {
- //邮箱不合法
- return;
- }
- var data = {
- account: $("#account").val(),
- phone: $("#phone").val(),
- mailbox: $("#mailbox").val(),
- comm: $("#comm").val()
- };
- Loading = true;
- //7.1.2 申请试用--添加
- $.ajax({
- type: "POST",
- url: $.baseUrl + "fc/add",
- dataType: "json",
- async: false,
- data: JSON.stringify(data),
- contentType: "application/json; charset=utf-8",
- success: function (data) {
- Loading = false;
- if (data.code === 0) {
- alert("申请成功");
- $("#account").val("");
- $("#phone").val("");
- $("#mailbox").val("");
- $("#comm").val("");
- $(".err_account").hide();
- $(".err_phone").hide();
- $(".err_mailbox").hide();
- } else {
- alert(data.msg);
- }
- }
- });
- });
- });
|