Since the HTML attributes are all directly attached to the HTML elements they affect, we were also able to get rid of several cases of auto-generated IDs that were no longer necessary.In MVC 3, we have a single flag to turn on unobtrusive Java Script mode, which enables both unobtrusive Ajax and unobtrusive client validation.
However, we have turned it on in the MVC 3 project template, so new projects will begin using the unobtrusive Java Script support by default.Additionally, you will need to enable client side validation (which remains off by default).To turn unobtrusive Java Script mode on/off and enable/disable client validation by default for the entire application, you can use Web.config: Using code to turn these features on or off actually behaves contextually.If those lines of code are present in your file, then it turns unobtrusive Java Script and client validation on or off for the whole application.A lightweight Java Script date library for parsing, validating, manipulating, and formatting dates. NET MVC 2, we shipped both client- and server-side validation support.
The client-side validation that we included in MVC 2 was a custom validation system written against ASP. We also included an experimental version written against j Query in the MVC Futures project. NET MVC 3 Beta, we’ve updated the runtime to enable a feature we’re calling “Unobtrusive Client Validation”. Specific technical details may change before the final release of MVC 3.We have also created a consumer for these unobtrusive client validation attributes that uses j Query and j Query Validate to perform the validation on our behalf. This release is designed to elicit feedback on features with enough time to make meaningful changes before MVC 3 ships, so please comment on this blog post or contact me if you have comments.With unobtrusive Java Script turned off, you will get this behavior, which is the same as MVC 2.(Make sure you scroll all the way to the right, to see the extent of the JSON.) When unobtrusive Ajax mode is enabled in MVC, the HTML that we generate looks significantly different: (Again, make sure you scroll all the way to the right, to see the extent of the HTML attributes.) The biggest change is obviously that we don’t emit the JSON blob any more.Instead, we’ve replaced the JSON with HTML 5-compatible attributes which describe the validators to be attached to the input fields.We’ve also attached some HTML attributes to the validation message spans so that they can be related to the input field they’re attached to.