'remove spell check on input WITH JAVASCRIPT

i have a JavaScript program that make input and a want to remove spell check.

let inp = document.createElement('input');
inp.placeholder = "enter line of code";
inp.autocomplete = "off";
//did not work
inp.spellcheck = "false";

i tried using inp.spellcheck = "false"; and it did not work however just spellcheck="false" on a input worked



Solution 1:[1]

If you work with the JavaScript DOM spellcheck property (as opposed to the HTML spellcheck attribute), you need to assign an actual boolean value, not a string.

const inp = document.body.appendChild(document.createElement('input'));
inp.placeholder = "enter line of code";
inp.autocomplete = "off";
inp.spellcheck = false; // not "false" which is a string

Solution 2:[2]

Set an attribute instead.

const inp = document.body.appendChild(document.createElement('input'));
inp.placeholder = "enter line of code";
inp.autocomplete = "off";
inp.setAttribute('spellcheck', 'false');

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 connexo
Solution 2 CertainPerformance