Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are Html.Validate and Html.ValidateFor methods for?

I'm finding it hard to find out helpful information about ASP.NET MVC's validation HTML helpers - Html.Validate and Html.ValidateFor.

Has anyone worked with these methods? what are they for?

like image 202
Shay Friedman Avatar asked May 02 '10 14:05

Shay Friedman


1 Answers

see this post for an answer

If there are situations where you don't actually want a validation message to visually appear for each field (i.e. by using Html.ValidationMessage), but would rather allow a summary to be the sole source of validation error messages (i.e. by using Html.ValidationSummary), you still need some way to "trigger" the validation to occur for the specific fields you want it to. This can be achieved by using the Html.Validate/Html.ValidateFor<> methods within your view. Those helpers won't render anything, but will simply register the specified field for client-side validation.

like image 72
SQueek Avatar answered Oct 12 '22 17:10

SQueek