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

类型错误:$(...).validate 不是函数

类型错误:$(...).validate 不是函数

慕哥9229398 2021-12-02 16:36:24
我正在创建一个登录页面,但我不确定为什么没有加载验证脚本。昨天我能够登录而没有像这样的错误。但是,当我今天尝试登录时,遇到了此错误。这是我的脚本的位置吗?我试过重新排列脚本,并检查其他文件,例如我的 js 和 jquery.validate.min.js 的文件位置,但一切似乎都很好。.html<meta http-equiv="content-type" content="text/html; charset=UTF-8" /><!--<meta http-equiv="refresh" content="5">--><!--<meta http-equiv="X-UA-Compatible" content="IE=edge" />--><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"><link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"><link rel="stylesheet" type="text/css" href="css/index.css"><link rel="stylesheet" href="https://code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css" /><script src="https://code.jquery.com/jquery-1.9.1.js"></script><script src="https://code.jquery.com/ui/1.10.2/jquery-ui.js"></script><link href="../Content/bootstrap.min.css" rel="stylesheet" /><script src="lib/jquery.validate.min.js"></script><!--<link href="css/jquery.mobile-1.4.5.min.css" rel="stylesheet" />--><script src="scripts/common.js"></script>.JSvar userid;var password; $(document).ready (function () {    $("#LoginForm").validate({   // this line is the error highlighted in console        messages: {            txtLogin: "User ID is required",            txtPassword: "Password is required",        },我相信我应该能够在解决这个问题后登录,因为我已经正确配置了我的 PHP 和其他文件。JS 文件似乎也不错。
查看完整描述

1 回答

?
ITMISS

TA贡献1871条经验 获得超8个赞

为了使用 的validation方法jQuery,您需要导入相关插件:


<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js"></script>

此外,在您的 JavaScript 文件的开头插入:


require('jquery-validation');

例如:


<form>

    <input required>

</form>

<script src="jquery.js"></script>

<script src="jquery.validate.js"></script>

<script>

    $("form").validate();

</script>

有关更多信息,请参阅官方文档。


查看完整回答
反对 回复 2021-12-02
  • 1 回答
  • 0 关注
  • 312 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信