Improvements are done or Unobstrusive Validations

2019-08-28 04:30发布

问题:

I was reading the new features of asp.net-mvc3 and found about unobtrusive-validation.

My question is that Unobstrusive is new in asp.net-mvc3?

This SO answer says about this validation

Does it mean that Model validation is improved by introducing the new feature called Unobtrusive

or

some improvements are done in Unobtrusive validations and this feature is already available if so, can you tell what are the improvements done?

回答1:

Unobtrusiveness has to do with the way validation rules are expressed rather than with validation process itself. From Scott Gu's blog post:

Unobtrusive JavaScript avoids injecting inline JavaScript into HTML, and enables cleaner separation of behavior using the new HTML 5 “data-“ attribute convention (which conveniently works on older browsers as well – including IE6). This keeps your HTML tight and clean, and makes it easier to optionally swap out or customize JS libraries.

And yes, this way of expressing validation rules in ASP.NET MVC is there since version 3.