-1

我尝试使用Foolproof版本 0.9.4518 中的 LessThanOrEqualTo 比较和验证另一个属性的 int,但它不起作用。

但是,它适用于日期时间格式,就像示例一样。

这是我的代码:

模型:

public partial class TryFoolProof {
    public int max { get; set;}

    [LessThanOrEqualTo("max")]
    public int? min{ get; set; }
}

我在视图中包含了脚本文件:(不知何故,NuGet 没有包含)

<script src="../../Scripts/jquery.js" type="text/javascript"></script>
<script src="~/Scripts/mvcfoolproof.unobtrusive.min.js"></script>
<script src="~/Scripts/MvcFoolproofJQueryValidation.min.js"></script>
<script src="~/Scripts/MvcFoolproofValidation.min.js"></script>

这是错误:

mvcfoolproof.unobtrusive.min.js:1 Uncaught TypeError: Cannot read property 'addMethod' of undefined
    at mvcfoolproof.unobtrusive.min.js:1
    at mvcfoolproof.unobtrusive.min.js:1
MvcFoolproofJQueryValidation.min.js:1 Uncaught TypeError: Cannot read property 'addMethod' of undefined
    at MvcFoolproofJQueryValidation.min.js:1
MvcFoolproofValidation.min.js:1 Uncaught ReferenceError: Sys is not defined
    at MvcFoolproofValidation.min.js:1

那么我怎样才能让它为 int 工作呢?

谢谢

4

1 回答 1

0

The scripts needed for client side validation using foolproof are, in order

jquery-{version}.js
jquery.validate.js
jquery.validate.unobtrusive.js
mvcfoolproof.unobtrusive.js

and you need to delete /MvcFoolproofJQueryValidation.min.js and MvcFoolproofValidation.min.js

In particular, you did not include jquery.validate.js so there is no validator to add the rules to.

于 2017-01-26T23:51:19.987 回答