Question

Im trying to us the Html.ValidationMessageFor(m=>m.MyProperty,"The field is very much required");

However.. Im alos using unobtrusive for my validations, but for some reason it seems like once Im using the customValidationMessage parameter, the unobtrusive validation for that property "breaks".

Or to put it in more simple terms... the validation message is always displayed, no matter if I enter a value or not.. it simply doesnt update/toggle.

The property is also used on a RadioButtonFor.. so the full "code" is:

@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")

Any ideas?

Était-ce utile?

La solution

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;
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top