Fixed copying mechanism

This commit is contained in:
2020-12-06 23:31:44 +01:00
parent 7e39d2dab9
commit 301ffc60f0
+22 -22
View File
@@ -10,12 +10,33 @@
<body class="center-screen"> <body class="center-screen">
<h1 th:text="|Dir wurde ein Code an ${name} gesendet!|"></h1>
<h2>Bitte gebe den Authentifizierungscode ein</h2>
<form action="#" id="passForm" th:action="@{/vote}" method="post">
<input id="voterName" type="hidden" name="name" th:value="${name}" />
<input id="authCode" type="hidden" name="code" value="" />
<input type="text" placeholder="•" class="passInput" name="pass[]" maxlength="1" autocomplete="off" required pattern="\d{1}" autofocus>
<input type="text" placeholder="•" class="passInput" name="pass[]" maxlength="1" autocomplete="off" required pattern="\d{1}">
<input type="text" placeholder="•" class="passInput" name="pass[]" maxlength="1" autocomplete="off" required pattern="\d{1}">
<input type="text" placeholder="•" class="passInput" name="pass[]" maxlength="1" autocomplete="off" required pattern="\d{1}">
<input type="text" placeholder="•" class="passInput" name="pass[]" maxlength="1" autocomplete="off" required pattern="\d{1}">
<input type="text" placeholder="•" class="passInput" name="pass[]" maxlength="1" autocomplete="off" required pattern="\d{1}">
</form>
<button class="submitButton" id="signup_button" onclick="getCode()">Abstimmen</button>
<div th:if="${codeExpired}">
<h2 class="errorCode">Der Code ist nicht mehr gültig!<br>Fordere einen neuen an</h2>
</div>
<div th:if="${codeFalse}">
<h2 class="errorCode">Der eingegebene Code ist falsch</h2>
</div>
<script> <script>
const $inp = $(".passInput"); const $inp = $(".passInput");
$inp.on({ $inp.on({
paste(ev) { // Handle Pasting paste(ev) { // Handle Pasting
const clip = ev.originalEvent.clipboardData.getData('text').trim(); const clip = ev.originalEvent.clipboardData.getData('text').trim();
// Allow numbers only // Allow numbers only
if (!/\d{6}/.test(clip)) return ev.preventDefault(); // Invalid. Exit here if (!/\d{6}/.test(clip)) return ev.preventDefault(); // Invalid. Exit here
@@ -50,27 +71,6 @@
} }
</script> </script>
<h1 th:text="|Dir wurde ein Code an ${name} gesendet!|"></h1>
<h2>Bitte gebe den Authentifizierungscode ein</h2>
<form action="#" id="passForm" th:action="@{/vote}" method="post">
<input id="voterName" type="hidden" name="name" th:value="${name}" />
<input id="authCode" type="hidden" name="code" value="" />
<input type="text" placeholder="•" class="passInput" name="pass[]" maxlength="1" autocomplete="off" required pattern="\d{1}" autofocus>
<input type="text" placeholder="•" class="passInput" name="pass[]" maxlength="1" autocomplete="off" required pattern="\d{1}">
<input type="text" placeholder="•" class="passInput" name="pass[]" maxlength="1" autocomplete="off" required pattern="\d{1}">
<input type="text" placeholder="•" class="passInput" name="pass[]" maxlength="1" autocomplete="off" required pattern="\d{1}">
<input type="text" placeholder="•" class="passInput" name="pass[]" maxlength="1" autocomplete="off" required pattern="\d{1}">
<input type="text" placeholder="•" class="passInput" name="pass[]" maxlength="1" autocomplete="off" required pattern="\d{1}">
</form>
<button class="submitButton" id="signup_button" onclick="getCode()">Abstimmen</button>
<div th:if="${codeExpired}">
<h2 class="errorCode">Der Code ist nicht mehr gültig!<br>Fordere einen neuen an</h2>
</div>
<div th:if="${codeFalse}">
<h2 class="errorCode">Der eingegebene Code ist falsch</h2>
</div>
</body> </body>