forked from haacked/aspnet-client-validation
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
haacked#97 delayed validation is now default behavior as per PR comme…
…nts. Fixed a bug with data-val-event not being respected
- Loading branch information
Andrew Korshunov
committed
Aug 15, 2024
1 parent
a59c47a
commit 22a1e84
Showing
9 changed files
with
54 additions
and
49 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
@page | ||
@model DemoWeb.Pages.Demos.ImmediateValidation | ||
@{ | ||
Layout = "Shared/_Layout"; | ||
} | ||
|
||
<div asp-validation-summary="All"> | ||
<span>Please correct the following errors</span> | ||
</div> | ||
|
||
<fieldset> | ||
<legend>Required Email input with data-val-event specified for immediate validation as you type.</legend> | ||
<form method="post"> | ||
<legend>Input with immediate validation (<code>data-val-event="input"</code>)</legend> | ||
<div class="form-field"> | ||
<label asp-for="EmailAddress"></label> | ||
<input asp-for="EmailAddress" data-val-event="input" /> | ||
<span asp-validation-for="EmailAddress"></span> | ||
</div> | ||
<legend>Input with default behavior</legend> | ||
<div class="form-field"> | ||
<label asp-for="AnotherEmailAddress"></label> | ||
<input asp-for="AnotherEmailAddress" /> | ||
<span asp-validation-for="AnotherEmailAddress"></span> | ||
</div> | ||
<input type="submit" value="Submit"/> | ||
</form> | ||
</fieldset> | ||
|
||
@section Scripts { | ||
<script> | ||
const service = new aspnetValidation.ValidationService(console); | ||
service.bootstrap(); | ||
</script> | ||
} |
10 changes: 7 additions & 3 deletions
10
Pages/Demos/DelayedValidation.cshtml.cs → Pages/Demos/ImmediateValidation.cshtml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,18 @@ | ||
using System.ComponentModel.DataAnnotations; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.AspNetCore.Mvc.RazorPages; | ||
using Microsoft.AspNetCore.Mvc.Rendering; | ||
using System.ComponentModel.DataAnnotations; | ||
|
||
namespace DemoWeb.Pages.Demos; | ||
|
||
public class DelayedValidation : PageModel | ||
public class ImmediateValidation : PageModel | ||
{ | ||
[BindProperty] | ||
[Required] | ||
[EmailAddress] | ||
public string? EmailAddress { get; set; } | ||
|
||
[BindProperty] | ||
[Required] | ||
[EmailAddress] | ||
public string? AnotherEmailAddress { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters