@page "/"
<h1>Hello, world!</h1>
Welcome to your new app.
<input value="@real" @oninput="HandleOnInput"/>
<pre>
This sample textbox changes the letter "a" to a period "." as you type (successfully).
This sample also tries to prevent the letter "x" from registering (fails).
To reproduce, type abxa in the text field, the result should be
typed should see actually see
======= =========== ===========
a . .
ab .b .b
abx .b .bx /// the letter x should be filtered out
abxa .b. .b.
This is similar to an issue I used to have with react.
In addition, the midstream text editing has a problem when trying to "get involved" in the input per keypress.
If you type in a string, then move the cursor to the middle and try to edit, the cursor WARPS to the end of the input.
This is similar to what is described here https://stackoverflow.com/a/49648061
- type "blazor" into the text field (should see bl.zor)
- then place the cursor before the "o" and type some more o's "oooo"
- the cursor will jump to the end of the input
</pre>
@code {
private string real = "";
void HandleOnInput(ChangeEventArgs ea)
{
Console.WriteLine($"HandleOnInput - {ea.Value.ToString()}");
var temp = ea.Value.ToString();
temp = temp.Replace("a", ".");
temp = temp.Replace("x", "");
real = temp;
Console.WriteLine($" - {real}");
}
}