简体   繁体   中英

What server validation logic transforms to unobtrusive client-side validation

In MVC3 you could write something like this:

[Required(ErrorMessage="Please fill some field that I need")]
public string someFieldThatINeed;

But what about custom validation attributes? Will they transforms to client-side javascript code and validate as well as embedded validation attributes do? Or do I need to write my own javascript client code? Thanks!

If custom attributes do not derive from some of the standard validation attributes or require some special validation logic you could implement the IClientValidatable and write custom client adapters. Here's an example .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM