Merge pull request #1634 from gjwalk/dev

reset validation
This commit is contained in:
Shaun Walker 2021-08-30 08:42:23 -04:00 committed by GitHub
commit acda6bba74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,6 +5,7 @@
@inject IStringLocalizer<Index> Localizer
@inject IStringLocalizer<SharedResources> SharedLocalizer
<form @ref="form" class="@(validated ? "was-validated" : "needs-validation")" novalidate>
<div class="container">
<div class="form-group">
<label for="Username" class="control-label">@SharedLocalizer["Username"] </label>
@ -12,17 +13,20 @@
</div>
<div class="form-group">
<label for="Password" class="control-label">@SharedLocalizer["Password"] </label>
<input type="password" class="form-control" placeholder="Password" @bind="@_password" id="Password" />
<input type="password" class="form-control" placeholder="Password" @bind="@_password" id="Password" required />
</div>
<div class="form-group">
<label for="Confirm" class="control-label">@Localizer["Password.Confirm"] </label>
<input type="password" class="form-control" placeholder="Password" @bind="@_confirm" id="Confirm" />
<input type="password" class="form-control" placeholder="Password" @bind="@_confirm" id="Confirm" required />
</div>
<button type="button" class="btn btn-primary" @onclick="Reset">@Localizer["Password.Reset"]</button>
<button type="button" class="btn btn-secondary" @onclick="Cancel">@SharedLocalizer["Cancel"]</button>
</div>
</form>
@code {
private ElementReference form;
private bool validated = false;
private string _username = string.Empty;
private string _password = string.Empty;
private string _confirm = string.Empty;
@ -42,6 +46,10 @@
}
private async Task Reset()
{
validated = true;
var interop = new Interop(JSRuntime);
if (await interop.FormValid(form))
{
try
{
@ -84,6 +92,11 @@
AddModuleMessage(Localizer["Error.Password.Reset"], MessageType.Error);
}
}
else
{
AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning);
}
}
private void Cancel()
{