I'm trying to find a way to select text in a text input if it fails my validation check. The behavior I'm after is that if it fails validation, it should highlight the text so that the user can just scan or type over it without needing to backspace. However, I would also like them to both be able to see what they attempted to enter and correct it if they can (i.e. if they just forgot to add 1 character at the end, they should be able to see that and hit the arrow key to keep the previously entered data instead of needing to type it all again). Basically I want to allow typing over the previous text but also the ability to keep it if it was mostly correct and just needed a small correction.
Is there any way to accomplish this?