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

2022-11-22 0 243

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("请填写必要信息!");
            }
        }
    });
});

 

1. 本站所有资源来源于用户上传和网络,因此不包含技术服务请大家谅解!如有侵权请邮件联系客服!cheeksyu@vip.qq.com
2. 本站不保证所提供下载的资源的准确性、安全性和完整性,资源仅供下载学习之用!如有链接无法下载、失效或广告,请联系客服处理!
3. 您必须在下载后的24个小时之内,从您的电脑中彻底删除上述内容资源!如用于商业或者非法用途,与本站无关,一切后果请用户自负!
4. 如果您也有好的资源或教程,您可以投稿发布,成功分享后有积分奖励和额外收入!
5.严禁将资源用于任何违法犯罪行为,不得违反国家法律,否则责任自负,一切法律责任与本站无关

源码下载

发表评论
暂无评论