@page "/"
<input value="@Answer" @oninput="OnInput" />
<p>:input:updated:Answer</p>
<p>@input @updated @Answer</p>
<p>Enter any series of digits.</p>
<p>If you enter more than two digits, input will be cleared.</p>
<p>If you enter '12', input will be cleared.</p>
<p>Same should happen for 8. I can't see why it fails.</p>
@code {
private string Answer = "";
private string input = "";
private string updated = "";
private void OnInput(ChangeEventArgs e) {
string answer = e.Value!.ToString()!;
input = ":" + answer;
if (answer == "12" || answer == "8") { // correct answer!
Answer = "";
// if (answer.Length == 1) {
// Console.WriteLine(Answer);
// } // uncomment this if you want to add a breakpoint when it should clear
} else if (answer.Length > 2) {
Answer = "";
} else {
Answer = answer;
}
updated = ":" + Answer + ":";
StateHasChanged();
}
}