JSFiddle - React, Tailwind, and code Playground

HTML

<form id="chatboxId" name="chatbox" class="userchat">
    <input class="userchat" name="message" type="text" onkeydown="if (event.keyCode == 13) document.getElementById('chatbutton').click()" />
    <br />
    <input class="userchat" id="chatbutton" name="submitmsg" type="button" onclick="submitChat()" value="Send" />
</form>

JavaScript

var form = document.getElementById("chatboxId"); // Select the appropriate form.

form.addEventListener("submit", function (event) {
    // Prevent the form from reloading the page.
    event.preventDefault(); // Try commenting this instruction and see the result.
    alert("Prevented the form from performing the normal submit action!");
});