Forum Discussion
Limiting Text Entry to One Character Issue
Hello everybody!
As I work on a crossword puzzle, I would like to limit the text entry fields to only contain one character.
Previously, in 2023, I have succeeded doing it using the JavaScript code down below, and it worked perfectly. Yet, when I tried to use it again, it doesn't seem to be working. Even when I opened my old project from 2023 and republished it again as a test or previewed in storyline it doesn't work anymore either.
I'm wondering if this is happening because there's some issue with storyline, maybe it has to be done differently now? Does anyone have an idea or have met and overcome the same issue?
Thanks.
Here's the JavaScript code somebody here suggested, that I used in my previous projects :
var elements = document.getElementsByTagName("input");
for (var i = 0, element; element = elements[i++];) {
element.setAttribute('maxlength', 1);
element.setAttribute('autocomplete', 'off');
}
Try
const Inputs = () => { const inputs = document.querySelectorAll('.acc-textinput'); inputs.forEach((input) => { input.setAttribute('maxlength', '1'); input.setAttribute('autocomplete', 'off'); }); } setTimeout(Inputs, 100);
- NedimCommunity Member
Try
const Inputs = () => { const inputs = document.querySelectorAll('.acc-textinput'); inputs.forEach((input) => { input.setAttribute('maxlength', '1'); input.setAttribute('autocomplete', 'off'); }); } setTimeout(Inputs, 100);
- Jenny_EDCommunity Member
This worked for me, thank you so much!