ASP.NET MVC3 比较验证器不工作

发布于 2024-12-27 10:35:15 字数 549 浏览 2 评论 0原文

我已经设置了用于比较密码的比较属性,如 this 博客。 但这不起作用。当我用谷歌搜索它时,我发现这是 jquery.validate.js 文件中的一个已知错误。

比较验证器是否有缺陷

Asp.net 论坛

我尝试了上面链接中给出的解决方案,但没有成功。

I have set compare attribute for comparing passwords as explained in this blog.
But it's not working. When I googled about it I found that it's a known bug in jquery.validate.js file.

Is the Compare Validator Bugged

Asp.net forum

I tried the solutions given in above links but no success.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

意中人 2025-01-03 10:35:15

描述

您正在混合服务器端和客户端。 DataAnnotation 属性 CompareAttribute 仅适用于服务器端。

但是您可以使用 jQuery 验证插件获得类似的功能。

示例

$.validator.addMethod("yourMethodName", function(value, element) {
    // compare and return
}

更多信息

查看这两个教程。

Description

You are mixing server and client side. The DataAnnotation Attribute CompareAttribute works only on server side.

But you can get similar functionality using the jQuery validation plugin.

Sample

$.validator.addMethod("yourMethodName", function(value, element) {
    // compare and return
}

More Information

Check out theese two tutorials.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文