0712-2888027 189-8648-0214
微信公众号

孝感风信网络科技有限公司微信公众号

当前位置:主页 > 技术支持 > Javascript/JQuery > JQuery用户提交登记信息进行验证的代码片段

JQuery用户提交登记信息进行验证的代码片段

时间:2024-04-27来源:风信官网 点击: 456次
以下为风信建站项目开发中所使用的JQuery用户提交登记信息进行验证的代码片段,分享给大家使用。
var $holder = $("body").on("click", ".quick-register .submit-btn,.quick-register-static .submit-btn", function() {
    var data = {},
        $this = $(this),
        $need = $this.parents('form').find('[name="need"]'),
        $phone = $this.parents('form').find('[name="phone"]'),
        $page = $this.parents('form').find('[name="page"]'),
        $price = $this.parents('form').find('[name="price"]'),
        $brand = $this.parent('form').find('[name="brand"]'),
	$category = $this.parent('form').find('[name="category"]'),
	$detail_id = $this.parent('form').find('[name="detail_id"]');
    data.need = $need.val();
    data.phone = $phone.val();
    data.page = $page.val();
    data.price = $price.val();
    data.detail_id = $detail_id.val();
    data.brand = $brand.val();
    data.category = $category.val();
    if (data.need.length == 0 || data.price.length == 0 || data.phone.length == 0) {
        if (ismobile) {
            return alert("请填写必要信息!");
        } else {
            return showAlert("请填写必要信息!");
        }
    }

    $.get('/quick_register', data, function(result) {
        // 登记成功之后
        if (result != 'no') {
        	leftPhoneFrom(data.phone, data.detail_id, data.need, data.brand, data.category);
            $('.quick-register-count').html(result);
            if($need.attr("type") != "hidden"){
                $need.val("");    
            }
            $phone.val("");
            vex.close();
            if (ismobile) {
                alert("提交成功!\n客服将会及时联系您!");
                if (location.pathname == '/quick_register/page') {
                    history.back();
                }
            } else {
                showAlert("提交成功!<br>客服将会及时联系您!", 0, function() {
                    if ($this.parents('.pop-register').find('.close-btn').length > 0) {
                        $this.parents('.pop-register').find('.close-btn').trigger("click");
                    }
                });
            }
        } else {
            if (ismobile) {
                alert("请填写必要信息!");
            } else {
                showAlert("请填写必要信息!");
            }
        }
    });
});
热门关键词: JQuery 用户提交 登记信息
栏目列表
推荐内容
热点内容
展开