what you need to do is first install the solution on the server side to perform your spellchecks , you can, for example, use PSpell . If you cannot install PSpell, you can use Googlespell (just remember to look at the terms of use). There are also some client-side implementation options (although not as reliable as server solutions).
There are many plugins to help you deal with spell checking, but for your Id task, go for something easier, like jQuery spellchecker .
Initiate your spelling case with the necessary parameters and create an event listener for your text field, a simple example would be:
var spellchecker = new $.SpellChecker('textarea', { lang: 'en', parser: 'text', webservice: { path: '../../webservices/php/SpellChecker.php', driver: 'pspell' }, suggestBox: { position: 'above' } }); $('textarea').keyup(function() {
Then you want to add a listener for the Spellchecker replace.word :
spellchecker.on('replace.word', function() {
If you want to do something more advanced, you can also try overriding Drupal built into the autocomplete Drupal.jsAC event .keyup() and see if the check.success event was check.success (words are spelled incorrectly). If there are no misspelled words, you use the drupals autocomplete implementation for onkeyup events. If misspelled words do nothing for these events.
var misspelledWord = false; spellchecker.on('check.success', function() { misspelledWord = false; }); spellchecker.on('check.fail', function() { misspelledWord = true; }); jQuery(document).ready(function(){ Drupal.jsAC.prototype.onkeyup = function (input, e) { if(misspelledWord) { if (!e) { e = window.event; } switch (e.keyCode) { case 16: // shift case 17: // ctrl case 18: // alt case 20: // caps lock case 33: // page up case 34: // page down case 35: // end case 36: // home case 37: // left arrow case 38: // up arrow case 39: // right arrow case 40: // down arrow return true; case 9: // tab case 13: // enter case 27: // esc this.hidePopup(e.keyCode); return true; default: // all other keys if (input.value.length > 0) this.populatePopup(); else this.hidePopup(e.keyCode); return true; } } }; });
However, it makes more sense for me to implement my own autocomplete using the jQuery AJAX function in spellcheckers replace.word event - you can also use / configure one of the jQuery autocomplete plugins.