Skip to content

Commit

Permalink
Add submit on Enter for sign in forms.
Browse files Browse the repository at this point in the history
  • Loading branch information
DL444 committed Oct 12, 2024
1 parent 00c8dc2 commit 64ff6c4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
15 changes: 12 additions & 3 deletions DL444.CquSchedule.Web/Components/SignInForm.razor
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
@using DL444.CquSchedule.Models;

<EditForm Model="Credential" autocomplete="off">
<div class="form-group mb-4">
<EditForm Model="Credential" autocomplete="off" OnValidSubmit="OnEditFormSubmit">
<div class="form-group mb-2">
<label for="usernameInput" class="mb-1">学号</label>
<InputText @bind-Value="Credential.Username" disabled="@Disabled" id="usernameInput" class="form-control mb-1" placeholder="2016----" />
<small class="form-text text-muted">请注意不是统一身份认证号</small>
</div>
<div class="form-group mb-4">
<div class="form-group mb-2">
<label for="passwordInput" class="mb-1">密码</label>
<InputText @bind-Value="Credential.Password" type="password" disabled="@Disabled" id="passwordInput" class="form-control mb-1" />
<small class="form-text text-muted">本科生为统一身份认证密码,研究生为 MIS 登录密码<br />不确定?先在 <a href="https://my.cqu.edu.cn/enroll" target="_blank">my.cqu.edu.cn</a> 或 <a href="http://mis.cqu.edu.cn/mis" target="_blank">mis.cqu.edu.cn</a> 测试</small>
</div>
<button type="submit" hidden />
</EditForm>

@code {
Expand All @@ -19,4 +20,12 @@

[Parameter]
public bool Disabled { get; set; }

[Parameter]
public EventCallback OnSubmit { get; set; }

private async Task OnEditFormSubmit()
{
await OnSubmit.InvokeAsync();
}
}
2 changes: 1 addition & 1 deletion DL444.CquSchedule.Web/Pages/AddCalendar.razor
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<h2>登录</h2>

<SignInForm Credential="credential" Disabled="inProgress" />
<SignInForm Credential="credential" Disabled="inProgress" OnSubmit="SubmitAsync" />

<p class="text-danger">@errorMessage</p>

Expand Down
2 changes: 1 addition & 1 deletion DL444.CquSchedule.Web/Pages/DeleteSubscription.razor
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<h3>登录</h3>

<SignInForm Credential="credential" Disabled="inProgress" />
<SignInForm Credential="credential" Disabled="inProgress" OnSubmit="SubmitAsync" />

<p class="text-danger">@errorMessage</p>

Expand Down

0 comments on commit 64ff6c4

Please sign in to comment.