Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable spell-checking on HTML textfields

Tags:

html

forms

People also ask

How do I turn off spell check in HTML?

Output: Disabling Spell Check in a HTML Form: To disable spellcheck in a HTML form the spellcheck attribute is set to “false”.

How do I turn off spell check in textarea?

To disable spell check in textarea atrribute spellcheck=”false” can be used.

How do I turn on spell check in HTML?

The spellcheck attribute specifies whether the element is to have its spelling and grammar checked or not. The following can be spellchecked: Text values in input elements (not password) Text in <textarea> elements.

How do I turn off spell check in CSS?

Tip: To disable the spell checking in the entire form at once — just set the spellcheck="false" in the <form> tag, like this <form spellcheck="false"> .


Update: As suggested by a commenter (additional credit to How can I disable the spell checker on text inputs on the iPhone), use this to handle all desktop and mobile browsers.

<tag autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>

Original answer: Javascript cannot override user settings, so unless you use another mechanism other than textfields, this is not (or shouldn't be) possible.


Yes, use spellcheck="false", as defined by HTML5, for example:

<textarea spellcheck="false">
    ...
</textarea>

For Grammarly you can use:

<textarea data-gramm="false" />

An IFrame WILL "trigger" the spell checker (if it has content-editable set to true) just as a textfield, at least in Chrome.


The following code snippet disables it for all textarea and input[type=text] elements:

(function () {
    function disableSpellCheck() {
        let selector = 'input[type=text], textarea';
        let textFields = document.querySelectorAll(selector);

        textFields.forEach(
            function (field, _currentIndex, _listObj) {
                field.spellcheck = false;
            }
        );
    }

    disableSpellCheck();
})();