Forum Discussion
Limiting Text Entry to One Character
Hi Selma,
I was able to do it but only using Javascript. There may be a better way by now. I had to define each letter in the puzzle as a variable. Then set the max length for that variable to 1. Here is a link to my puzzle. https://carolinatigerrescue.org/wp-content/games/crossword/story_html5.html
It would be enhanced by adding a popup to say you can only add one character, if you try to enter more than one. Or simply replacing the last character entered. But I'm not goof enough with scripting for that on my own.
Here is just a snippet of the code I used.
var fields = "1DownLetter1";
(function setMaxChars(fields) {
fields.forEach(function (field, field_index) {
$('[placeholder=' + field + ']').attr('id',field);
$("#1DownLetter1").attr("maxlength","1");
$('[placeholder=' + field + ']').attr('placeholder', '');
});
})(fields);
- 0555331405553315 years agoCommunity Member
HelloDawn Can you help me, how can I apply this? I've been trying this code by Execute Javascript trigger when timeline starts, but it's not working.
Related Content
- 11 months ago
- 8 months ago