Unobtrusive Validation means without writing a lot of validation code, you can perform simple client-side validation by adding the suitable attributes and including the suitable script files.
These unobtrusive validation libraries need to be added:
Bower: bower install jquery-validation
NuGet: Install-Package jQuery.Validation
NPM : npm i jquery-validation
Installation via Package Managers:
- data-val-required=”This is required.”
- data-val-email=”Error message”
- data-val-maxlength=”Error message”
- data-val-maxlength-max=”Maximum length (e.g. 5)”
- data-val-minlength=”Error message”
- data-val-minlength-min=”Minimum length (e.g. 2)”
List of some data validation attribute:
Method for unobtrusive validation:
Firstly, we need to add those libraries in the script of HTML files. These libraries provide a list of data attributes (data-val, data-val-required, and many more) for validation. Then the form should be built according to the requirements in which different types of data attributes can be used.
- Form validation using jQuery
- Form validation using jQuery Poppa Plugin
- AngularJS | Form Validation
- Laravel | Validation Rules
- Form required attribute with a custom validation message in HTML5
- ES6 | Validation
- How to Display Validation Message for Radio Buttons with Inline Images using Bootstrap 4 ?
- How to create form validation by using only HTML ?
- jQuery | jQuery.fx.interval Property with example
- jQuery | jQuery.fx.off Property
- jQuery | jQuery.support Property
- jQuery | jquery Property
- JQuery | Multiple ID selectors
- jQuery | :input Selector
- jQuery | prepend() with Examples
- jQuery | dblclick() with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.