BlazorBasics.Captcha 1.0.1

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

// Install BlazorBasics.Captcha as a Cake Tool
#tool nuget:?package=BlazorBasics.Captcha&version=1.0.1                

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 net7.0 is compatible.  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 was computed.  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. 
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.1.5 93 10/10/2024
1.0.4 92 7/28/2024
1.0.2 245 1/13/2024
1.0.1 214 7/23/2023