Set digit pattern to Solution captcha
This commit is contained in:
parent
1d72fe222b
commit
419334febe
1 changed files with 2 additions and 4 deletions
|
@ -4,11 +4,9 @@
|
||||||
|
|
||||||
const a = Math.floor(Math.random() * 80) + 20
|
const a = Math.floor(Math.random() * 80) + 20
|
||||||
const b = Math.floor(Math.random() * 80) + 20
|
const b = Math.floor(Math.random() * 80) + 20
|
||||||
let ok = true
|
|
||||||
const eventDispatcher = createEventDispatcher()
|
const eventDispatcher = createEventDispatcher()
|
||||||
function newValue(val: number) {
|
function newValue(val: number) {
|
||||||
ok = a + b == val
|
if (a + b == val) {
|
||||||
if (ok) {
|
|
||||||
eventDispatcher("done")
|
eventDispatcher("done")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,5 +14,5 @@
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<p>Úlohu zatím nemáš vyřešenou, opravdu si chceš vyzradit řešení?</p>
|
<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>
|
</div>
|
||||||
|
|
Reference in a new issue