Constraining the input value of type number to max value does not work (Blazor) #33736
Labels
area-blazor
Includes: Blazor, Razor Components
✔️ Resolution: Answered
Resolved because the question asked by the original author has been answered.
Status: Resolved
Milestone
`
Number Input
@code { private int inputVal; private int maxInputVal = 100;<input id="my-val" type="number" max="@maxInputVal" value="@inputval" @oninput="InputChangeHandler">
}
`
I am trying to constrain an input value to a max value in the input element box of type number so that if the user tries to put a value exceeding the max value it will automatically set it to the max value on oninput event. the problem is it works only first when you exceed the value, e.g if maxVal=100 and you set 200 in the input box it will change it to 100 but now if you set 1000 it does not rerender the input box with 100. you will see 1000 on UI despite the binding variable is 100. it happens because the binding variable value is still equal to the old value. there should be a way to explicitly rerender the element because there are many use cases in our code where we have to constrain the max value to a certain number.
I am invoking Javascript method to this for now as a workaround.
The text was updated successfully, but these errors were encountered: