Finbuckle.Html5Validation
1.0.1
Prefix Reserved
dotnet add package Finbuckle.Html5Validation --version 1.0.1
NuGet\Install-Package Finbuckle.Html5Validation -Version 1.0.1
<PackageReference Include="Finbuckle.Html5Validation" Version="1.0.1" />
paket add Finbuckle.Html5Validation --version 1.0.1
#r "nuget: Finbuckle.Html5Validation, 1.0.1"
// Install Finbuckle.Html5Validation as a Cake Addin #addin nuget:?package=Finbuckle.Html5Validation&version=1.0.1 // Install Finbuckle.Html5Validation as a Cake Tool #tool nuget:?package=Finbuckle.Html5Validation&version=1.0.1
Finbuckle.Html5Validation
Introduction
Client form validation in ASP.NET Core sucks.
Specifically, tag helpers and HTMLHelper
methods
generate non-standard validation attributes
and require the use of the jquery.validate
and jquery.validate.unobtrusive
libraries.
This library overrides this behavior to generate standard HTML5 validation attributes.
If you like this library, check out our main project Finbuckle.MultiTenant and consider becoming a sponsor.
Installation
Add the
Finbuckle.Html5Validation
NuGet package to your project.Add the
Html5Validation
service to your app:
using Finbuckle.Html5Validation;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddHtml5Validation();
// Rest of app code omitted.
Supported Data Annotations
The following data annotations are supported:
Attribute | ASP.NET Core | Finbuckle.Html5Validation | |
---|---|---|---|
[Required] |
- data-val=true <br> - data-val-required="{message}" |
- required |
|
[MinLength] |
- minlength="{min}" <br> - data-val=true <br> - data-val-minlength="{message}" <br>- data-val-maxlength-min="{min}" |
- minlength="{min}" |
|
[MaxLength] |
- maxlength="{max}" <br> - data-val=true <br> - data-val-maxlength="{message}" <br>- data-val-maxlength-max="{max}" |
- maxlength="{max}" |
|
[StringLength] |
- maxlength="{max}" <br> - data-val=true <br> - data-val-maxlength="{message}" <br>- data-val-maxlength-max="{max}" <br> - data-val-minlength="{message}" <br> - data-val-maxlength-min="{min}" |
- minlength="{min}" <br> - maxlength="{max}" |
|
[Range] |
- data-val=true <br> - data-val-range="{message}" <br> - data-val-range-min="{min}" <br>- data-val-range-max="{max}" |
- min="{min}" <br> - max="{max}" |
|
[RegularExpression] |
- data-val=true <br> - data-val-regex="{message}" <br> - data-val-regex-pattern="{regex}" |
- pattern="{regex}" |
|
[DataType(DataType.{type}] |
- type="{type}" <br> - data-val-{type}="{message}" |
- type="{type}" |
|
[EmailAddress] |
- type="email" <br> - data-val-email="{message}" |
- type="email" |
|
[Phone] |
- type="tel" <br> - data-val-phone="{message}" |
- type="tel" |
|
[Url] |
- type="url" <br> - data-val-url="{message}" |
- type="url" |
Note that
[DataType(DataType.{type})]
only supports simple types such as email, phone, and url.`
Installation
Add the
Finbuckle.Html5Validation
NuGet package to your project.In your app configuration add the
Html5Validation
service:
using Finbuckle.Html5Validation;
var builder = WebApplication.CreateBuilder(args);
// ... Add normal services.
// Add Finbuclke.Html5Validation.
builder.Services.AddHtml5Validation();
// ... rest of file omitted.
License
This project is licensed under the MIT License. See LICENSE file for license information.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- No dependencies.
-
net8.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.