首页 > 其他分享 >jquery.validate 验证弹窗显示

jquery.validate 验证弹窗显示

时间:2022-10-18 10:12:50浏览次数:50  
标签:jquery false newPwd res oldPwd error validate data 弹窗

@{
    Layout = null;
}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>ChangePwd</title>
    <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=1" name="viewport" />
    <link rel="stylesheet" href="~/web/css/base.css">
    <link rel="stylesheet" href="~/web/css/loyalty.css">
    <script src="~/web/js/jquery-1.11.3.min.js"></script>
    <script src="~/web/js/font.js"></script>
    <script src="~/vue/vue.js"></script>
    <script src="~/vue/axios.min.js"></script>
    <script src="~/vue/storage.js"></script>
    <script src="~/vue/jquery.validate.js"></script>
    <script src="~/layer/layer.js"></script>
</head>
<body>
    <div data-role="page">
        <div data-role="header" data-position="fixed" data-tap-toggle="false">
            <header class="head">
                <div class="header">
                    <div class="headerTop topcenter">
                        <div class="boxflex topcenter">
                            <a href="/home/main" data-rel="back" data-ajax="false" data-role="none" class="backMenuBtn"><img src="~/web/images/icon_back.png" alt="" class="backImg"></a>
                            <div class="headertit boxflex">Change Password</div>
                        </div>
                    </div>
                </div>
            </header>
        </div>
        <div data-role="main" id="app">
            <div class="loyalty_sign_box">
                <form action="" class="loyalty_sign_form loyalty_form" data-ajax="false" id="commentForm" method="post" novalidate="novalidate" validate-event="false">
                    <div class="loyalty_sign_block">
                        <div class="loyalty_sign_block_name">Original Password</div>
                        <input type="text" name="oldPwd" id="oldPwd" class="loyaltyInput" data-role="none" placeholder="original password" v-model="oldPwd">
                    </div>
                    <div class="loyalty_sign_block">
                        <div class="loyalty_sign_block_name">New Password</div>
                        <input type="text" name="newPwd" id="newPwd" class="loyaltyInput" data-role="none" placeholder="new password:5-10 characters" v-model="newPwd">
                    </div>
                    <div class="loyalty_sign_block">
                        <div class="loyalty_sign_block_name">New Password</div>
                        <input type="text" name="confirmPwd" id="confirmPwd" class="loyaltyInput" data-role="none" placeholder="retype new password" v-model="confirmPwd">
                    </div>
                    <div class="loyalty_btn_box">
                        <input type="button" value="Modify" data-role="none" class="radius_btn green_btn" id="btn" v-on:click="submitForm">
                    </div>
                </form>
            </div>
        </div>
    </div>
    <script>
        $(function () {
            $("#commentForm").validate({
                onclick: true,
                onfocusout: false,
                onkeyup: false,
                onkeyup: false,
                onsubmit: false,
                errorPlacement: function (error, element) {
                    layer.tips(error.html(), '#' + element[0].id, {
                        tips: 3,
                        tipsMore: true
                    });
                },
                rules: {
                    oldPwd: { required: true },
                    newPwd: { required: true },
                    confirmPwd: { equalTo: "#newPwd" }
                },
                messages: {
                    oldPwd: { required: "请输入旧密码!" },
                    newPwd: { required: "请输入新密码!" },
                    confirmPwd: { equalTo: "密码不一致!" },
                }
            });
        });
        var vm = new Vue({
            el: '#app',
            data: {
                oldPwd: "",
                newPwd: "",
                confirmPwd: "",
            },
            methods: {
                submitForm() {
                    var flag = $("#commentForm").valid();
                    if (!flag) {
                        return;
                    } else {
                        axios({
                            method: 'post',
                            url: '/Home/ChangePwdJson',
                            // 自定义请求头
                            headers: { 'Content-Type': 'application/json;charset=utf-8', 'token': storage.get("token") },
                            // timeout: 1000, // 默认值是 `0` (永不超时)
                            data: {
                                old_pwd: this.oldPwd,
                                new_pwd: this.newPwd,
                                confirm_pwd: this.confirmPwd
                            }
                        }).then(res => {
                            if (res.data.Code == 100) {
                                location.href = "/home/main";
                            } else {
                                if (res.data.Code == 104) { location.href = "/home/login"; }
                                else {
                                    alert(res.data.Msg);
                                }
                            }
                        }).catch(function (error) { // 请求失败处理
                            console.log('error' + error);
                        });
                    }
                }
            }
        });

    </script>
</body>
</html>

 

标签:jquery,false,newPwd,res,oldPwd,error,validate,data,弹窗
From: https://www.cnblogs.com/elsons/p/16801650.html

相关文章

  • vant2 自动检查表单验证 -validate
    ref给 <van-form@submit="onSubmit"ref="form">标签;//检验手机号是否合格awaitthis.$refs.form.validate("mobile");data里面定义的规则rules对象......
  • JQuery常用方法总结(转)
    原文连接:https://www.cnblogs.com/rainMicro/p/7158788.htmlAttribute:$(”p”).addClass(css中定义的样式类型);给某个元素添加样式$(”img”).attr({src:”test.jpg”,a......
  • jquery append()和appendTo() 的区别
    append()和appendTo()的区别append()$(selector).append(content,function(index,html))在A的后面添加Bcontent,可以是HTML元素,jQuery对象,DOM元素,<script>$(func......
  • jquery 事件绑定及取消 bind live delegate on one区别 (超详细且通俗易懂)
    onbinddelegatelive one四种方法差别不是特别大bind讲完后,后面的方法只会说不同点1.bind()$(selector).bind(event,data,function,map)event必需。规定添加到元素的一个......
  • jquery animate()方法 动画详解(超简单易懂)
    jqueryanimate动画详解(超简单易懂)animate()方法是jquery里的动画效果,通过修改css相关属性,在规定时间内,值是不断变化的从而形成了一种动画的效果。(selector).animate({style......
  • jquery 节点的删除
    1.remove()2.detach()3.empty()1.remove()remove()方法移除被选元素,包括所有的文本和子节点,以及数据和事件。$(function(){$('ul').remove()})<ulclass="5......
  • jquery鼠标移入移出事件显示div
    <liclass="active"><divclass="PartR"></div></li><scripttype="text/javascript">$(function(){//显示隐藏varcolor......
  • 直播带货源码,HTML + jQuery 实现轮播图
    直播带货源码,HTML+jQuery实现轮播图HTML页面部分1、首先创建可视窗口添加6张图片,添加CSS样式 2、添加左右切换按钮,设置样式 3、添加图片导航器,设置样式,添加悬......
  • JQuery .nextAll()
    https://www.jquery123.com/nextAll/ 获得每个匹配元素集合中所有下面的同辈元素,选择性筛选的选择器。如果一个jQuery对象代表了一组DOM元素,.nextAll()方法允许我们在D......
  • jQuery的.attr()方法
    https://blog.csdn.net/weixin_42648692/article/details/86294123attr()方法是jQuery操作属性的一个方法。可以根据参数的不同,来获取或设置属性值。.attr()方法常用的四......