-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make sure input.form exists before accessing it
Fixes #47
- Loading branch information
Showing
10 changed files
with
105 additions
and
31 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
@page | ||
@model DemoWeb.Pages.Demos.RemovedInputs | ||
|
||
@{ | ||
Layout = "Shared/_Layout"; | ||
} | ||
|
||
<partial name="Shared/_StatusMessage" model="Model.StatusMessage"/> | ||
|
||
<fieldset> | ||
<legend>Required ASP.NET Checkboxes with hidden input</legend> | ||
|
||
<form method="post"> | ||
<div class="form-field"> | ||
<p> | ||
This simple test demonstrates that we don't validate removed inputs. | ||
</p> | ||
|
||
<div id="value1" class="form-control"> | ||
<label>Value 1 | ||
<input asp-for="Value1"/> | ||
<span asp-validation-for="Value1"></span> | ||
</label> | ||
</div> | ||
|
||
<div id="value2" class="form-control my-1"> | ||
<label>Value 2 | ||
<input asp-for="Value2"/> | ||
<span asp-validation-for="Value2"></span> | ||
</label> | ||
</div> | ||
|
||
<button type="button" onclick="document.getElementById('value2').parentNode.removeChild(document.getElementById('value2'))">Remove Value 2 Input</button> | ||
|
||
<input type="submit" value="Input Type Submit" /> | ||
</div> | ||
</form> | ||
</fieldset> |
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,26 @@ | ||
using System.ComponentModel.DataAnnotations; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.AspNetCore.Mvc.RazorPages; | ||
|
||
namespace DemoWeb.Pages.Demos; | ||
|
||
public class RemovedInputs : PageModel | ||
{ | ||
[TempData] | ||
public string? StatusMessage { get; set; } | ||
|
||
[BindProperty] | ||
[Required] | ||
public string? Value1 { get; set; } | ||
|
||
[BindProperty] | ||
[Required] | ||
public string? Value2 { get; set; } | ||
|
||
public IActionResult OnPost() | ||
{ | ||
StatusMessage = "Form was submitted"; | ||
|
||
return RedirectToPage(); | ||
} | ||
} |
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.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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