How to Toggle Spell Checker on HTML Input Fields?

As per the W3 spec, you can use the spellcheck attribute on HTML input fields (such as <input> and <textarea>) to toggle browser's built-in spell checker on or off. It has the following values:

  • spellcheck="true" or spellcheck — enables spell checker;
  • spellcheck="false" — disables spell checker.

For example, to disable spell checking you would set the spellcheck attribute to false like so:

<input type="text" spellcheck="false" />
<textarea spellcheck="false"></textarea>

To enable spell checking you would either set the spellcheck attribute to true or omit the value, for example, like so:

<input type="text" spellcheck />
<textarea spellcheck></textarea>
<input type="text" spellcheck="true" />
<textarea spellcheck="true"></textarea>

This post was published by Daniyal Hamid. Daniyal currently works as the Head of Engineering in Germany and has 20+ years of experience in software engineering, design and marketing. Please show your love and support by sharing this post.