为了账号安全,请及时绑定邮箱和手机立即绑定

啊!!就是没有效果呀,代码正确,引入地址也是对的

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
    <style>
        fieldset{
            width: 400px;
            border:1px solid pink;
        }
    </style>
</head>
<body>
<script src="https://cdn.jsdelivr.net/npm/jquery-validation@1.19.1/dist/jquery.validate.js"></script>
<script src="https://libs.baidu.com/jquery/1.9.1/jquery.js"></script>
<button id="yjh">点这</button>
<script>
$('#yjh').click(function(){
    alert("这个有用");
})
</script>

<script>
    $(document).ready(function(){//当页面载入后

        $('#demoForm').validate({//以下约定的是name值
            rules:{
                username:{
                    required:true,
                    minlength:2,
                    maxlength:10
                },
                password:{
                    required:true,
                    minlength:2,
                    maxlength:16
                }
            },
            messages:{//提示信息
                username:{
                    required:"必须填写用户名",
                    minlength:"用户名最小为2位",
                    maxlength:"最大为40位"
                },
                password:{
                    required:"必须填写密码",
                    minlength:"最小为2位",
                    maxlength:"最大为16位"
                }
            }
        });
    });

</script>
    <div>
        <form id="demoForm">
            <fieldset>
                <legend>用户登录</legend>
                <label for="username">用户名:</label><!-- for的作用:当点击用户名时使鼠标聚焦在输入框 -->
                <input type="text" id="username" name="username"><br>

                <label for="password">密&nbsp;&nbsp;&nbsp;码:</label>
                <input type="password" id="password" name="password"><br>

                <input type="submit" name="" value="登录">
                <input type="reset" name="" value="重置">
            </fieldset>
        </form>
    </div>
</body>
</html>

正在回答

1 回答

jquery的引入顺序反了,要先引入

<script src="https://libs.baidu.com/jquery/1.9.1/jquery.js"></script>

然后再引入Validate:<script src="https://cdn.jsdelivr.net/npm/jquery-validation@1.19.1/dist/jquery.validate.js"></script>

 

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

啊!!就是没有效果呀,代码正确,引入地址也是对的

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信