2020-09-11 17:33:43 -06:00
|
|
|
|
---
|
|
|
|
|
pre:
|
|
|
|
|
authors:
|
|
|
|
|
- neale
|
|
|
|
|
scripts:
|
|
|
|
|
- filename: helpers.js
|
|
|
|
|
- filename: draggable.js
|
|
|
|
|
answers:
|
|
|
|
|
- helper
|
|
|
|
|
debug:
|
|
|
|
|
summary: Using JavaScript Input Helpers
|
|
|
|
|
---
|
2019-02-24 15:51:40 -07:00
|
|
|
|
MOTH only takes static answers:
|
|
|
|
|
you can't, for instance, write code to check answer correctness.
|
|
|
|
|
But you can provide as many correct answers as you like in a single puzzle.
|
|
|
|
|
|
|
|
|
|
This page has an associated `helpers.js` script
|
|
|
|
|
you can include to assist with input formatting,
|
|
|
|
|
so people aren't confused about how to enter an answer.
|
|
|
|
|
|
2019-02-24 17:02:28 -07:00
|
|
|
|
You could also write your own JavaScript to validate things.
|
2019-02-24 15:51:40 -07:00
|
|
|
|
|
|
|
|
|
This is just a demonstration page.
|
|
|
|
|
You will probably only want one of these in a page,
|
|
|
|
|
to avoid confusing people.
|
|
|
|
|
|
2020-09-11 17:33:43 -06:00
|
|
|
|
### RFC3339 Timestamp
|
2019-04-18 21:58:34 -06:00
|
|
|
|
<div class="answer" data-join="">
|
|
|
|
|
<input type="date">
|
|
|
|
|
<input type="hidden" value="T">
|
|
|
|
|
<input type="time" step="1">
|
|
|
|
|
<input type="hidden" value="Z">
|
|
|
|
|
</div>
|
2019-02-24 15:51:40 -07:00
|
|
|
|
|
2020-09-11 17:33:43 -06:00
|
|
|
|
### All lower-case letters
|
2019-02-24 15:51:40 -07:00
|
|
|
|
<input class="answer lower">
|
|
|
|
|
|
2020-09-11 17:33:43 -06:00
|
|
|
|
### Multiple concatenated values
|
2019-02-24 15:51:40 -07:00
|
|
|
|
<div class="answer lower">
|
|
|
|
|
<input type="color">
|
|
|
|
|
<input type="number">
|
|
|
|
|
<input type="range" min="0" max="127">
|
|
|
|
|
<input>
|
|
|
|
|
</div>
|
|
|
|
|
|
2020-09-11 17:33:43 -06:00
|
|
|
|
### Free input, sorted, concatenated values
|
2019-04-10 13:56:17 -06:00
|
|
|
|
<ul class="answer lower sort">
|
|
|
|
|
<li><input></li>
|
2019-04-10 14:04:04 -06:00
|
|
|
|
<li><button class="expand" title="Add another input">➕</button><l/i>
|
2019-04-10 13:56:17 -06:00
|
|
|
|
</ul>
|
|
|
|
|
|
2020-09-11 17:33:43 -06:00
|
|
|
|
### User-draggable values
|
2019-09-09 18:31:34 -06:00
|
|
|
|
<ul class="answer">
|
|
|
|
|
<li draggable="true"><input value="First" readonly></li>
|
|
|
|
|
<li draggable="true"><input value="Third" readonly></li>
|
|
|
|
|
<li draggable="true"><input value="Second" readonly></li>
|
|
|
|
|
</ul>
|
|
|
|
|
|
2020-09-11 17:33:43 -06:00
|
|
|
|
### Select from an ordered list of options
|
2019-02-24 15:51:40 -07:00
|
|
|
|
<ul class="answer">
|
|
|
|
|
<li><input type="checkbox" value="horn">Horns</li>
|
|
|
|
|
<li><input type="checkbox" value="hoof">Hooves</li>
|
|
|
|
|
<li><input type="checkbox" value="antler">Antlers</li>
|
|
|
|
|
</ul>
|
2020-09-11 17:33:43 -06:00
|
|
|
|
|
|
|
|
|
### Substring matches
|
|
|
|
|
#### Any substring
|
|
|
|
|
<input class="answer substring">
|
|
|
|
|
|
|
|
|
|
#### Only if at the beginning
|
|
|
|
|
<input class="answer substring anchor-beg">
|
|
|
|
|
|
|
|
|
|
#### Only if at the end
|
|
|
|
|
<input class="answer substring anchor-end">
|