What's the reason behind MVC's (Visual Studio's) behaviour to create ValidationMessageFor() calls in scaffolded views for boolean properties? For instance, the Razor views when scaffolded look like this
@Html.EditorFor(model => model.IsTaxable)
@Html.ValidationMessageFor(model => model.IsTaxable)
However, the same goes for ASP.NET View engine views. What can we validate in single boolean fields? Now that it uses EditorFor I can see cases where custom templates would be used and we might have for instance three possible options and only two of them would be regular, so in this case I see a distant reason for validation but it was like this in MVC v1 and v2 too, where boolean was scaffolded as checkbox.
In the case of checkbox, there really is no need for valid开发者_如何学JAVAation and it actually produces more trouble for developer because we have to delete all the validation helper calls if we want unchecked checkboxes to validate.
Anyone?
You might want to validate that the user has selected the checkbox. For example that he has accepted the terms and conditions.
精彩评论