Answered by:
What does jquery.validate.unobtrusive.js add over jquery.validate..js?

Question
-
User-1158769213 posted
Hello,
I've been using jquery.validate.js to provide client-side validation, and have finally noticed that MVC projects come with a file called jquery.validate.unobtrusive.js as well.
What does this add that jquery.validate.js doesn't have?
Thanks
Thursday, March 14, 2019 4:06 PM
Answers
-
User839733648 posted
Hi Yossu,
jquery Validation is just a javascript plugin. It makes simple clientside form validation easy. Reference: https://jqueryvalidation.org/
jquery.validate.unobtrusive.js is simply Javascript validation that doesn't pollute your source code with its own validation code.
Here is articles about jquery.validate.unobtrusive.js:
https://bradwilson.typepad.com/blog/2010/10/mvc3-unobtrusive-validation.html
https://bradwilson.typepad.com/blog/2010/10/mvc3-unobtrusive-ajax.html
For more about the two's relationship, you could refer to:
( jQuery Validation is just a javascript plugin used by Microsoft through its custom javascript named Microsoft jQuery Unobstrusive plugin to make ASP.Net MVC validation on client side a quiet simple. )
Best Regrads,
Jenifer
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Friday, March 15, 2019 3:05 AM
All replies
-
User475983607 posted
What does this add that jquery.validate.js doesn't have?The docs cover the details.
Thursday, March 14, 2019 4:17 PM -
User-1158769213 posted
Thanks for the reply. Sadly, that link is for the repo, which has extremely little in the way of useful info.
I'm not at the stage of contributing to the project, I want to know what the library offers that jquery.validate..js doesn't. What motivation would I have for using it?
Thanks anyway.
Thursday, March 14, 2019 6:36 PM -
User475983607 posted
Yossu
Thanks for the reply. Sadly, that link is for the repo, which has extremely little in the way of useful info.
I'm not at the stage of contributing to the project, I want to know what the library offers that jquery.validate..js doesn't. What motivation would I have for using it?
Thanks anyway.
Unobtrusive means the JavaScript validation is added to the site to enhances the UI for those users taking advantage of JavaScript. It uses the data- attributes to standardize validation configuration MVC HTML helpers use the same mechanism when rendering model with validation attributes. I believe unobtrusive started in MVC 3 so those docs might be a better source than the new ASP.NET Core docs. I prefer reading the source code. Sorry if I offended you by point to the source.
Google is also a good resource for this type of information.
Thursday, March 14, 2019 6:56 PM -
User-1158769213 posted
No offence at all, I appreciate the help!
So are you saying that if I have validation rules set in my model (ie the C# class), then the helpers will add the appropriate data-* attributes? If so, then it saves a lot of setting up in the regular jquery.validation code.
Thanks
Thursday, March 14, 2019 8:24 PM -
User839733648 posted
Hi Yossu,
jquery Validation is just a javascript plugin. It makes simple clientside form validation easy. Reference: https://jqueryvalidation.org/
jquery.validate.unobtrusive.js is simply Javascript validation that doesn't pollute your source code with its own validation code.
Here is articles about jquery.validate.unobtrusive.js:
https://bradwilson.typepad.com/blog/2010/10/mvc3-unobtrusive-validation.html
https://bradwilson.typepad.com/blog/2010/10/mvc3-unobtrusive-ajax.html
For more about the two's relationship, you could refer to:
( jQuery Validation is just a javascript plugin used by Microsoft through its custom javascript named Microsoft jQuery Unobstrusive plugin to make ASP.Net MVC validation on client side a quiet simple. )
Best Regrads,
Jenifer
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Friday, March 15, 2019 3:05 AM -
User-1158769213 posted
Thanks, that was very helpful.
Tuesday, March 19, 2019 2:22 PM