Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Turn off grammar correction in a contenteditable div in FireFox

I have contenteditable div with text on it. In firefox, there is some kind of grammar correction which underlines the text with red marking. How can I turn it off? Why-do.you-underline-me-image

How do I turn off the red markings in FireFox?

<div contenteditable ='true'>Why do you underline me?</div>

JSFiddle: http://jsfiddle.net/26JkW/

like image 636
einstein Avatar asked Apr 25 '11 20:04

einstein


3 Answers

Try --

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

Since the above is a Firefox-only attribute, if you're concerned about validation, you can also use jQuery to set the attribute, e.g.

$('.textarea_you_want_to_target').attr('spellcheck', false);


Update

It seems in Firefox you have to set spellcheck="false" on <body>. See http://jsfiddle.net/26JkW/5/

like image 90
stealthyninja Avatar answered Oct 16 '22 09:10

stealthyninja


There is no grammar-checking native to Firefox. Given that every word is being marked as incorrect, it is possible that you have the wrong language selected.

To verify that you have the correct language selected for Firefox's dictionary: When typing in an editable field, right-click the input area. From the context menu, there is an option Languages. Ensure the expected language is selected.


EDIT stealthyninja's answer below contains the method for disabling spell checking as the OP requested. This answer should not be taken as the solution.

like image 44
Chris Baker Avatar answered Oct 16 '22 08:10

Chris Baker


According to MDN:

Starting in Gecko 9.0 (Firefox 9.0 / Thunderbird 9.0 / SeaMonkey 2.6), the spell checker uses the <input> element's lang attribute to determine the default spell checker language. If <input> doesn't have a lang attribute, that attribute is searched each successive parent element and upward toward the root node until one is found.

So to disable spellcheck, not only do I add spellcheck="false", but I also add a lang tag with a dictionary not found on the users computer.

<div contentEditable="true" lang="klingon" spellcheck="false"></div>

This should work on most systems outside of Kronos.

like image 4
donavon Avatar answered Oct 16 '22 10:10

donavon