Scripting numeric textfield component


I want to realise following functionality with a numeric text field:
users should enter an ID ( only digits). After entering an ID, pressing Enter should confirm the input. In the keyPressed event script, I want to display relevant information based on the entered ID. However, I'm facing challenges in retrieving the entered ID and preventing users from entering invalid characters.

Could someone help?

This is a repeat post, which is against this forum's rules. It is reasonable to add a comment on a post after a couple days to bring more attention to an unanswered question.