Can I disable "return" key while entering text?

In the game the player has to enter a code word. When they finish, they press enter or mouse click a button to validate the code word. The mouse click works but if they press enter, before the “validation” script runs, the enter adds a new line to the text and, as a result, the code does not match the one that’s on file. Can I disable “enter” key from the text field so that it doesn’t add that new line and, instead, runs the “validation” script?

 void Update()
    {
        if (Input.GetKeyDown(KeyCode.Return))
        {
               PlayerCodeEntered();
        }
   }

You should be able to set your Input field as a single-line entry, which stops Enter from creating a new line.