Way to remove newline from end of text input?

I’m trying to remove the newline from the end of a text input’s text value. When the user types in something and presses return, the cursor moves down to the next line I want to remove that newly-added newline character.

I’ve tried text substitution by replacing all [newline] and all “\n” in the text input’s text but it doesn’t do anything.

Any ideas about how to achieve that?

For now, I’ve disabled multiline in the text input’s properties as a workaround. It prevents the newline from being added but it still registers the submit event.