用户注册时在输入账号的时候如果已存在该账户则出现提示信息

// 当注册账户已存在
        $('.login-form').find('.address-email').on('input', function () {
            var $this = $(this),
                email = $.trim($this.val()),
                pattern = /\w+([\-+.']\w+)*@\w+([\-.]\w+)*\.\w+([\-.]\w+)*/,
                ajaxRegisterEmail,
                recognised = $this.next('.recognised'),
                submitBtn = $this.parent().siblings('.buttons').find('.btn-submit');

            if (ajaxRegisterEmail !== undefined) {
                ajaxRegisterEmail.abort();
            }

            if (email !== '' && pattern.test(email)) {
                ajaxRegisterEmail = $.ajax({
                    url: eventure.getUncachedUrl('/Base/BaseHandler'),
                    type: 'POST',
                    data: {
                        pt: 'check-email-exist',
                        email: email
                    },
                    success: function (data) {
                        if (data.status === 'f') {
                            recognised.show().text(data.message);
                            $this.addClass('input-validation-error');
                            submitBtn.addClass('disabled').removeClass('btn-red').prop('disabled', true);
                        } else {
                            recognised.hide();
                            $this.removeClass('input-validation-error');
                            submitBtn.removeClass('disabled').addClass('btn-red').prop('disabled', false);
                        }
                    }
                })
            }

        });

  

posted @ 2018-03-15 17:59  林间小语  阅读(952)  评论(1编辑  收藏  举报