1

我试图给我们 Html.ValidationMessageFor(m=>m.MyProperty,"The field is very much required");

但是..我也使用不显眼的验证进行验证,但由于某种原因,似乎一旦我使用 customValidationMessage 参数,该属性的不显眼验证就会“中断”。

或者用更简单的术语来说......无论我是否输入一个值,都会始终显示验证消息......它根本不会更新/切换。

该属性也用于 RadioButtonFor.. 所以完整的“代码”是:

@Html.RadioButtonFor(m=>m.Myproperty,"Value 1")
@Html.RadioButtonFor(m=>m.Myproperty,"Value 2")
@Html.ValidationMessageFor(m=>m.MyProperty,"Please select ine of the options")

有任何想法吗?

4

1 回答 1

6

have you included these jquery libraries?

jquery-1.9.2.js
jquery.validate.js
jquery.validate.unobtrusive.js

If already, add this css style in page.

.field-validation-valid
{
    display: none;
}
.validation-summary-valid
{
    display: none;
}
于 2014-04-30T09:30:09.007 回答