為什么沒有效果呀,有沒有大神有現(xiàn)在可以引用插件鏈接
<!DOCTYPE html>
<html>
<head>
?? ?<meta charset="utf-8">
?? ?<title></title>
?? ?<style>
?? ??? ?fieldset{
?? ??? ??? ?width: 400px;
?? ??? ??? ?border:1px solid pink;
?? ??? ?}
?? ?</style>
</head>
<body>
<script src="jq-cj/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(){//當(dāng)頁面載入后
?? ??? ?$('#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的作用:當(dāng)點擊用戶名時使鼠標(biāo)聚焦在輸入框 -->
?? ??? ??? ??? ?<input type="text" id="username" name="username"><br>
?? ??? ??? ??? ?<label for="password">密 碼:</label>
?? ??? ??? ??? ?<input type="password" id="password" name="password"><br>
?? ??? ??? ??? ?<input type="submit" name="" value="登錄">
?? ??? ??? ??? ?<input type="reset" name="" value="重置">
?? ??? ??? ?</fieldset>
?? ??? ?</form>
?? ?</div>
</body>
</html>
2020-08-16
<script src="jq-cj/dist/jquery.validate.js"></script>
<script src="
引用順序錯了,要倒過來,先引用jquery再引用jquery.validate