I am having an issue with a form submitting twice on a single click. I have removed all of the other code from the page. There is no javascript. There are no styles set. I have many other pages with the same input and they work fine. I have a log file which shows that the handler was called twice in the same second. I realize that many devs have to deal with the issue where the user clicks the submit button twice. I even tried implementing the suggested javascript to disable the button on click. Didnāt help. I am definitely not clicking twice. I have recreated the issue many times.
This is a user management form with an add user button. Every time I click it it adds two users and, yes, the handler in my Go code gets called twice.
Here is the stripped down page:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Users</title>
</head>
<body>
<form action="/generalLedger" method="get">
<input name = "userID" value = "admin" hidden>
<input name = "hashedPassword" value = "£¢”" hidden>
<input class="input-button" name="addUser" type="submit" value="Add User" id="addUser_btn">
</form>
</body>
</html>
On the server this is the request received:
/generalLedger?userID=admin&hashedPassword=%C2%A3%C2%A2%C2%A1&addUser=Add+User
userID=admin
hashedPassword=%C2%A3%C2%A2%C2%A1
addUser=Add+User
This request shows up in the log twice