Forum Discussion
Disable spellcheck in text entry fields
That's quite a puzzle. Quick answer: your javascript function only selects the first instance of that element within the course (document).
The javascript code you've used will only queryselector the first input or textarea and not all. You'd have to modify that to be a querySelectoAll function and then iterate/loop over each item found and update the attribute of each. The link above supports the ability to match two selectors and then iterate and update the attribute of inputs and text areas at the same time.
However, if a user is using a tablet or ipad etc for your elearning then the keyboard tool itself has a separate spell check and word recommendations that browser-based solutions likely can't disable. Also, if the user is using a grammar plugin like grammarly then grammarly disables the spellcheck attribute and adds it's own attributes to check spelling and grammar. You can test and see some of this here: https://developer.grammarly.com/docs/demo . I tried to disabled it on that page and was unsuccessful, here are some comments about it: https://stackoverflow.com/questions/37444906/how-to-stop-extensions-add-ons-like-grammarly-on-contenteditable-editors#:~:text=To%20disable%20Grammarly%2C%20you%20can,of%20them%20to%20be%20safe.
But Grammarly may not be the only one out there to contend with. Perhaps the nature of your assessment could assume a spellchecker is always available but a rationale must be provided by your candidates? Best of luck.
Hopefully I don't have any typos here!
Thanks for the detailed reply, Josh! As you say, there are several factors to consider. I don't have the course enabled for mobile devices, so that's one less headache. Grammarly et al are a completely new can of worms! :-)
For the moment, removing the conditions from the existing code worked:
document.querySelector("input").setAttribute("spellcheck", "false");
document.querySelector("textarea").setAttribute("spellcheck", "false");
It's doing the job - until the next time!
Related Content
- 12 months ago
- 2 years ago
- 9 years ago
- 4 months ago