From 2e2acdff91c575a648a31134a81e7aef065c35ab Mon Sep 17 00:00:00 2001
From: Carl Worth <cworth@cworth.org>
Date: Sun, 3 May 2020 10:54:57 -0700
Subject: [PATCH] Use an actual "submit" input element instead of a "button"

This has the advantage of allowing the user to just press the Enter
key on any field of the form in order to submit it. For this we move
the invocation of our javascript handler for the form submission from
onclick() of the button to onsubmit() of the form itself. Finally, we
have to reutnr false from our new onsubmit() handler so that the
browser doesn't reload the page (which would clear the message that
results from a new player being added).
---
 empires/index.html | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/empires/index.html b/empires/index.html
index 2e539e7..7b44445 100644
--- a/empires/index.html
+++ b/empires/index.html
@@ -26,14 +26,15 @@
   <div id="message-area">
   </div>
 
-  <form>
+  <!-- The return false prevents the page from being reloaded -->
+  <form onsubmit="register(this); return false">
     <label for="name">Your name</label>
     <input type="text" id="name" required>
 
     <label for="character">Character name</label>
     <input type="text" id="character" required>
 
-    <input type="button" value="Join game" onclick="register(this.form)">
+    <input type="submit" value="Join game">
   </form>
 
 </body>
-- 
2.45.2