Skip to content
Form and Validation Helper for ASP.NET Core. (Compatible with Fluent Validation)
Branch: master
Clone or download
Latest commit 7d06348 May 18, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
sample/FormHelper.Samples Added modal usage to the sample project. May 18, 2019
src/FormHelper Version updated to 1.1.1 May 18, 2019
.gitattributes First push, hello github :) May 5, 2019
.gitignore First push, hello github :) May 5, 2019
FormHelper.sln Project path changed. May 7, 2019
README.md Update README.md May 18, 2019

README.md

Form Helper

Form & Validation Helper for ASP.NET Core

FormHelper helps you to create ajax forms and validations without writing any javascript code. It transforms server-side validations to client-side. You can also use the form validator without ajax.

Compatible with Fluent Validation (You can add client-side validation support to Fluent Validation.)

NuGet Nuget

FormHelper

Installation

FormHelper can be installed using the Nuget Package Manager or the dotnet CLI.

Package Manager:

Install-Package FormHelper

dotnet CLI:

dotnet add package FormHelper

This library depends on some packages:

CDN:

<script src="//cdnjs.cloudflare.com/ajax/libs/jquery.form/4.2.2/jquery.form.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.19.0/jquery.validate.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-validation-unobtrusive/3.2.11/jquery.validate.unobtrusive.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.js"></script>

Usage

Startup.cs

services.AddFormHelper();

With configuration: (optional)

services.AddFormHelper(new FormHelperConfiguration
{
    UsePascalCaseJson = true,
    CheckTheFormFieldsMessage = "Your custom message...",
    RedirectDelay = 6000,
    DebugMode = true
});

View:

var formConfig = new FormConfig(ViewContext)
{
    FormId = "ProductForm",
    FormTitle = "New Product",
    BeforeSubmit = "ProductFormBeforeSubmit", // optional
    Callback = "ProductFormCallback" // optional,
};

// <form id="@formConfig.FormId" asp-controller="Home" asp-action="Save"
// ...

@await Html.RenderFormScript(formConfig)

Controller:

[HttpPost, FormValidator]
public IActionResult Save(FormViewModel viewModel)

Return a result from Controller:

Error Message:

return FormResult.CreateErrorResult("An error occured.");

Warning Message:

return FormResult.CreateWarningResult("'ABC' is already exist in the database.");

Info Message:

return FormResult.CreateInfoResult("Happy new year!");

Success Message:

return FormResult.CreateSuccessResult("Product saved.");

Success Message with Redirect:

return FormResult.CreateSuccessResult("Product saved. Please wait...", Url.Action("Home", "Index"));

Blog Posts

English:
English Posts are not ready yet. But you can look the samples. It's so easy to use.

Turkish:
FormHelper ve Fluent Validation kullanarak ASP.NET Core Validation İşlemleri

You can’t perform that action at this time.