BlazorBasics.Captcha 1.1.5

There is a newer version of this package available.
See the version list below for details.
dotnet add package BlazorBasics.Captcha --version 1.1.5
                    
NuGet\Install-Package BlazorBasics.Captcha -Version 1.1.5
                    
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="BlazorBasics.Captcha" Version="1.1.5" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="BlazorBasics.Captcha" Version="1.1.5" />
                    
Directory.Packages.props
<PackageReference Include="BlazorBasics.Captcha" />
                    
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 BlazorBasics.Captcha --version 1.1.5
                    
#r "nuget: BlazorBasics.Captcha, 1.1.5"
                    
#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 BlazorBasics.Captcha@1.1.5
                    
#: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=BlazorBasics.Captcha&version=1.1.5
                    
Install as a Cake Addin
#tool nuget:?package=BlazorBasics.Captcha&version=1.1.5
                    
Install as a Cake Tool

Nuget Nuget

BlazorBasics.Captcha

Add a captcha control into your Balzor Server or Blazor Webassembly application

How to use

Nugget installation PM> Install-Package BlazorBasics.Captcha Or clone the repository and add the project to your solution.<br/> Use the component CaptchaComponent into the component you want to check a real user.

<CaptchaComponent />

Parameters

CaptchaProperties Properties;						//how to configure the captcha
EventCallback<bool> OnValidate;						//delegate to execute when validate the captcha
Func<Task<IEnumerable<CaptchaItem>>> DataSource;	//delegate from where get the CaptchaItems to validate
RenderFragment BeforeValidate;						//content to show before validate
RenderFragment AfterValidate;						//content to show after validate
EventCallback OnSubmit;								//delegate to use when default button is set different of submit
Dictionary<string, object> WrapperAttributes;		//attributes for the container of the HTML

Entities

namespace BlazorBasics.Captcha.Entities;

public enum ButtonType
{
    Submit, Button, Reset
}

public class CaptchaItem
{
    public string Question { get; set; }
    public string Response { get; set; }
    public bool Selected { get; set; }

    public CaptchaItem() { }

    public CaptchaItem(string question, string response) : this(question, response, false) { }

    public CaptchaItem(string question, string response, bool selected)
    {
        Question = question;
        Response = response;
        Selected = selected;
    }
}

public record struct CaptchaProperties(
    CaptchaType Type = CaptchaType.Numeric, 
    string Description = "", 
    string Placeholder = "", 
    ButtonType Button = ButtonType.Submit, 
    string ErrorMessage = "Not Match!");

public enum CaptchaType
{
    Numeric, CountryCapitals, Custom
}

Personalize content

<EditForm Model="ContactUsForm" OnValidSubmit="SendForm">
    <div class="columns">
        <div class="column">
            <div class="field">
                <label class="label"></label>
                <div class="control">
                    <InputText class="input" type="email" placeholder="Email Address" @bind-Value=Email />
                </div>
            </div>
        </div>
    </div>
    <div class="columns">
        <CaptchaComponent class="column" Properties=MyCaptcha>
            <BeforeValidate>
                <span class="button is-link">Solve math</span>
            </BeforeValidate>
            <AfterValidate>
                <div class="column">
                    <button type="submit" class="button is-info">SEND MESSAGE</button>
                </div>
            </AfterValidate>
        </CaptchaComponent>
    </div>
</EditForm>

@code{
    string Email;

    CaptchaProperties MyCaptcha = new CaptchaProperties(
        Type: CaptchaType.Numeric,
        ErrorMessage: "Solve the math correctly please...");

    void SendForm(){
        //some code...
    }
}
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 was computed.  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.

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
1.2.7 108 5/31/2025
1.2.6 156 12/27/2024
1.1.5 135 10/10/2024
1.0.4 124 7/28/2024
1.0.2 271 1/13/2024
1.0.1 242 7/23/2023

Removed NET6 and NET7 support. Update Nugets.