To access user input from an included script, we need to add  .value at the end of document.getElementById().

Add .value to access the user input in the text field.

<html>
<head><style>body {min-height: 300px;} input { font-size: 16px; } textarea { font-size: 16px; } </style></head>
<body>
  <input id="usernameInput" type="text" placeholder="Username">
  <button onclick="register()">Register</button>
  <p id="message"></p>
  
  <script>var username = document.getElementById("usernameInput").value;</script>
</body>
</html>]]>

Make sure to assemble .value.