Browse Source

Set digit pattern to Solution captcha

mj-deploy
Standa Lukeš 4 years ago
parent
commit
419334febe
  1. 6
      frontend/src/SolutionCaptcha.svelte

6
frontend/src/SolutionCaptcha.svelte

@ -4,11 +4,9 @@
const a = Math.floor(Math.random() * 80) + 20
const b = Math.floor(Math.random() * 80) + 20
let ok = true
const eventDispatcher = createEventDispatcher()
function newValue(val: number) {
ok = a + b == val
if (ok) {
if (a + b == val) {
eventDispatcher("done")
}
}
@ -16,5 +14,5 @@
<div>
<p>Úlohu zatím nemáš vyřešenou, opravdu si chceš vyzradit řešení?</p>
{a} + {b} = <input type=text pattern={"" + a + b} on:input={e => newValue(+e.currentTarget.value)}>
{a} + {b} = <input type=text pattern="[0-9]+" on:input={e => newValue(+e.currentTarget.value)}>
</div>