Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I'd recommend not using [Required] for this, as [Required] and subclassed types have the special meaning of being <em>always</em> required - not conditionally required.</p> <p>You can make your own attribute which subclasses ValidationAttribute and carries along client-side validation info. There are several resources available for how to write custom client-side validation code. For example, see:</p> <ul> <li><a href="http://blogs.msdn.com/b/stuartleeks/archive/2010/07/27/asp-net-mvc-adding-client-side-validation-to-validatepasswordlengthattribute.aspx" rel="nofollow">http://blogs.msdn.com/b/stuartleeks/archive/2010/07/27/asp-net-mvc-adding-client-side-validation-to-validatepasswordlengthattribute.aspx</a></li> <li><a href="http://devermind.com/aspnet-mvc/asp-net-mvc-tip-3-how-to-cover-all-your-client-side-form-validation-needs-without-writing-any-javascript-part1/" rel="nofollow">http://devermind.com/aspnet-mvc/asp-net-mvc-tip-3-how-to-cover-all-your-client-side-form-validation-needs-without-writing-any-javascript-part1/</a></li> </ul> <p>In MVC 3, you can use IClientValidatable for this, which makes life a little simpler. See <a href="http://blogs.msdn.com/b/stuartleeks/archive/2010/07/28/asp-net-mvc-adding-client-side-validation-to-validatepasswordlengthattribute-in-asp-net-mvc-3-preview-1.aspx" rel="nofollow">http://blogs.msdn.com/b/stuartleeks/archive/2010/07/28/asp-net-mvc-adding-client-side-validation-to-validatepasswordlengthattribute-in-asp-net-mvc-3-preview-1.aspx</a> for an example.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload