Anyone have a clever way to trim spaces in a TextBox after the user tabs away from it? I have a TextBox with a requiredvalidator and a regex validator and they work fine. But in the onchange, I'm doing a val1 = val1.Trim() and it reloads the new bound data into the textbox. However, my regex is failing it and it shouldn't?
It's like the regex validator doesn't see the bound object change it's value. I've tried forcing a form validation, but the regex validator is still failing the "old" value?
What are you trying to achieve? Did you try using the Change event of the RadzenTextBox? Also how is the validator configured? There are too many unknowns for us to help.
As I mentioned in my first post, yes, I am using OnChange event to do a Trim() on the bound variable. What I am trying to achieve:
Have a required validator.
Have a regex validator.
Trim spaces out of the textbox when the user tabs out of it.
Everythings works, except when trimming the spaces...the regex validator is failing the text that's in the box and it is 100% valid. The validator is still seeing the spaces?
Ok, tried forcing validation...the form submitted ok, but the red validation text was still on the screen after the base variable was trimmed. The regex validator didn't update itself? How do I get the validator to hide it's text if it's matched?
Here is the screen when the validator is passed...notice the red text is visible...it should NOT be! I am positive the forced validation is happening...I set a breakpoint.
The problem is that changing the property does not immediately update the component Value. Blazor needs to run its data-binding before that. Try the following:
Could I ask for a new feature....perhaps a trim property for RadzenTextBox that would either prevent entry of leading/trailing spaces or remove them when the control loses focus? Removing trailing spaces is unfortunately a common occurrence and the presence of them will cause a RegEx validator to fail unless they are removed.
Thank you so much for the help, it is appreciated!
Excellent! Thank you for the great support!! The autoscroll you added to the outline panel has greatly improved my productivity when working on large complex forms...thank you for that too!