<input value="@Answer" @oninput="OnInput" />Enter any series of digits.
If you enter more than two digits, input will be cleared.
If you enter '12', input will be cleared.
Same should happen for 8. I can't see why it fails.
@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(); }}Try it here:
https://blazorfiddle.com/s/bgudkadp