If you're interested, I've implemented such a solution in my mod. It consists in only allowing digits to be entered. That's how I do it for the target altitude field of my mod:
View attachment 132214
Doing this, any non-digit character will be ignored, including the comma. You lose the possibility to enter decimal numbers, but this also prevents the user from entering unreadable data (such as letters). It already occured to me, as I just wanted to pilot my ship, but still had the focus on the angle field.