Finbuckle.Html5Validation 9.0.0

Prefix Reserved
dotnet add package Finbuckle.Html5Validation --version 9.0.0
                    
NuGet\Install-Package Finbuckle.Html5Validation -Version 9.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Finbuckle.Html5Validation" Version="9.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Finbuckle.Html5Validation" Version="9.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Finbuckle.Html5Validation" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Finbuckle.Html5Validation --version 9.0.0
                    
#r "nuget: Finbuckle.Html5Validation, 9.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Finbuckle.Html5Validation@9.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Finbuckle.Html5Validation&version=9.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Finbuckle.Html5Validation&version=9.0.0
                    
Install as a Cake Tool

Finbuckle.Html5Validation

  1. Introduction
  2. What's New in v<span class="_version">9.0.0</span>
  3. Installation
  4. Supported Data Annotations
  5. FAQ
  6. License

Introduction

Client side form validation in ASP.NET Core stinks.

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.

<a name="whats-new"></a> What's New in v<span class="_version">9.0.0</span>

This section only lists release update details specific to v<span class="_version">9.0.0</span>. See the changelog file for all release update details.

⚠ BREAKING CHANGES

  • .NET 6 support removed

Features

  • add .NET 9 and package lockfile support (21606eb)

Installation

  1. Add the Finbuckle.Html5Validation NuGet package to your project.

  2. 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] - minlength="{min}"<br> - 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=true<br> - data-val-{type}="{message}" - type="{type}"
[EmailAddress] - type="email"<br> - data-val=true<br> - data-val-email="{message}" - type="email"
[Phone] - type="tel"<br> - data-val=true<br> - data-val-phone="{message}" - type="tel"
[Url] - type="url"<br> - data-val=true<br> - data-val-url="{message}" - type="url"

Note that [DataType(DataType.{type})] only supports simple types such as email, phone, and url.

Installation

  1. Add the Finbuckle.Html5Validation NuGet package to your project.

  2. 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.

FAQ

  • Why not just use the jquery.validate and jquery.validate.unobtrusive libraries?

    These libraries are not standard HTML5 validation attributes and require additional JavaScript libraries to work. This library generates standard HTML5 validation attributes that work out of the box with modern browsers.

  • Does it have any imapct on server side validation?

    No, this library only affects client-side validation.

  • Does this library work with Blazor?

    No, this library only works with ASP.NET Core MVC Razor Pages and MVC apps that use tag helpers and HTMLHelper form input methods.

License

This project is licensed under the MIT License. See LICENSE file for license information.

Product Compatible and additional computed target framework versions.
.NET 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.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.
  • net9.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.

Version Downloads Last Updated
9.0.0 236 5/14/2025
1.0.1 3,383 6/21/2024
1.0.0 142 6/21/2024