javascript – Jquery验证插件 – TypeError:$(…).validate不是函数
作者:互联网
我的脚本抛出错误:
TypeError: jQuery.validator is undefined additional-methods.js:20
TypeError: $(…).validate is not a function index.php:115
可能,我在jQuery代码中有错误.
<head>
<script type="text/javascript" src="js/jquery-1.10.2.js"></script>
<script type="text/javascript" src="js/jquery.form.js"></script>
<script src="http://jquery.bassistance.de/validate/additional-methods.js"></script>
</head>
<body>
<form id="registerForm" method="post" action="logrej.php">
<input name="login" type="text"/>
<input name="nick" type="text"/>
<input type="password" id="passw" name="password"/>
<input type="password" name="retype" />
<input type="submit" value="Zarejestruj!" />
</form>
<script>
$("#registerForm").validate({
rules: {
login: {
required:true,
rangelenght: [4,20],
remote:"look.php"
},
nick : {
required:true,
rangelenght:[4,20],
remote:"look.php"
},
password: {
required:true,
rangelenght:[4.20]
},
retype: {
required:true,
equalTo:"#passw"
}
},
messages:{
login:{
required:"To pole jest wymagane!"
}
}
})
</script>
解决方法:
您没有加载验证插件.你需要:
<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js"></script>
将它放在加载其他方法的行之前.
此外,您还应该从CDN获取其他方法,而不是jquery.bassistance.de.
其他错误:
[4.20]
应该
[4,20]
和
rangelenght:
应该:
rangelength:
标签:javascript,jquery,jquery-validate 来源: https://codeday.me/bug/20190923/1813732.html