特性“lay-verify”未知

提问 未结 20 598
董明
董明 2020-4-1
悬赏:20飞吻
版本:layui 2.5.6 浏览器:IE11


开始学习LayUI, 在VS2013下开发的第一支就有错误提示,请教大家,多谢!


<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title>登录</title>

<script src="~/Scripts/layui/layui.js"></script>
<link href="~/Scripts/layui/css/layui.css" rel="stylesheet" />
<link href="~/Scripts/Self/login.css" rel="stylesheet" />

</head>
<body class="beg-login-bg">
<div class="beg-login-box">
<header>
<h1>系统登录</h1>
</header>
<div class="beg-login-main">
<form action="#" class="layui-form" method="post">

<div class="layui-form-item">
<label class="beg-login-icon">
<i class="layui-icon"></i>
</label>
<input type="text" name="fNr" lay-verify="fNr" autocomplete="off" placeholder="这里输入登录名" class="layui-input">
</div>

<div class="layui-form-item">
<label class="beg-login-icon">
<i class="layui-icon"></i>
</label>
<input type="password" name="fPwd" lay-verify="fPwd" autocomplete="off" placeholder="这里输入密码" class="layui-input">
</div>

<div class="layui-form-item">

<div class="beg-pull-right">
<button class="layui-btn layui-btn-primary" lay-submit lay-filter="login">
<i class="layui-icon"></i> 登录
</button>
</div>
<div class="beg-clear"></div>

</div>
</form>
</div>
<footer>
<p>SZTA © http://www.szta.com</p>
</footer>
</div>

<script>


layui.use(['layer', 'form'], function () {
var layer = layui.layer,
$ = layui.jquery,
form = layui.form();

form.on('submit(login)', function (obj) {
var user = obj.field;
$.ajax({
type: "POST",
url: "@Url.Action("chkLogin")",
data: user,
success: function (result) {
if (result.Success == true) {
window.location.href = "@Url.Action("Index")"
}
else {
layer.msg(result.Message, { icon: 5 });
}
}
})
});
});


</script>
</body>
</html>
回帖
  • Jameszyq
    2020-4-1
    而且你用了自定义的表单验证,但那个验证规则,你也没写吧
    1 回复
  • Jameszyq
    2020-4-1
    这只是警告吧,不是错误,不影响页面运行吧
    0 回复
  • Paran0id
    2020-4-1
    ide的警告无视就好了
    0 回复
  • 董明
    2020-4-1
    运行就报错,根本进不了debugger;位置
    <script>

    layui.use(['layer', 'form'], function () {
    var layer = layui.layer,
    $ = layui.jquery,
    form = layui.form();

    form.on('submit(login)', function (obj) {
    debugger;

    var user = obj.field;
    $.ajax({
    type: "POST",
    url: "@Url.Action("chkLogin")",
    data: user,
    success: function (result) {
    if (result.Success == true) {
    window.location.href = "@Url.Action("Index")"
    }
    else {
    layer.msg(result.Message, { icon: 5 });
    }
    }
    })
    });
    });


    </script>
    0 回复
  • Jameszyq
    2020-4-1
    @董明 报什么错,错误信息发出来
    0 回复
  • IDyun
    2020-4-1
    idea eclipse 编辑器忽略 未知标签、属性 提醒
    https://fly.layui.com/jie/43401/#item-1547308422351
    0 回复
  • 董明
    2020-4-1
    对没写, 抄过来的, 谢谢
    0 回复
  • 董明
    2020-4-1
    在后台验证

    public ActionResult chkLogin(string fNr, string fPwd)
    {
    using (dbEntities db = new dbEntities())
    {
    syUser obj = db.syUsers
    .FirstOrDefault(a => a.fNr == fNr);
    if (obj == null)
    {
    return Json(new { Success = false, Message = "当前用户不存在!" });
    }
    if (obj.fPwd != fPwd)
    {
    return Json(new { Success = false, Message = "当前用户密码不存在!" });
    }

    return Json(new { Success = true, Message = "登录成功!" });
    }
    }
    0 回复
  • 董明
    2020-4-1
    可以运行, 得不执行click事件

    0 回复
  • 董明
    2020-4-1
    0 回复