Make sure that the element is loaded in DOM before you try to fetch its value.
Consider interacting with the Mendix data model instead of trying to attach to the input box itself. When you enter a value into the input, it writes that value into its corresponding attribute. In a nanoflow or JS action, you can easily fetch the value of an attribute. Similarly, if you change the value of an attribute in a nanoflow or JS action, the value of the text box will be updated too.