jQuery auto-correct plugin

For times when a spell check is over kill! Many of us have over a period of time acquired some bad typing habits and we mis-spell some common word like typing 'teh' for 'the' and 'taht' instead of 'that'. Going back and correcting every instance of this mistake can be very frustrating - so rather than change habit here is a jQuery plugin which will auto-correct such mistakes as you type

Take a look at the Demo

Works with jQuery-1.3.2 on all latest versions of major browsers like Firefox, Seamonkey, Chrome, IE, Safari, Opera etc.

Usage

Include plugin file in your page after the jQuery file

Configure your textboxes/textareas something like

CODE:
  1. $(document).ready(function()
  2. {
  3.     $("#textbox1").autocorrect();
  4.  
  5.     $("#textbox2").autocorrect({
  6.         corrections: {
  7.             arent: "aren't",
  8.             aboutit: "about it"
  9.         }
  10.     });
  11.  
  12.     $("#textarea").autocorrect({ corrections: { aboutit: "about it" } });
  13. });

As you see, first textbox has auto-correct attached with no options, second with 'arent' (which already exists in default options but you can over-write it) and 'aboutit' (this is new one which does not exist in default corrections) then third one is textarea

Download : here

About Amit Badkas

Amit Badkas is Zend certified PHP5 and Zend Framework engineer, and has been working in SANIsoft for past 9 years, his present designation is 'Technical Manager'

7 Responses to jQuery auto-correct plugin

  1. Tom Barry August 9, 2011 at 6:59 pm #

    I've noticed a small bug with this extremely useful plug in. If you type the word 'watch' it will return a named function converted to a string!

    My fix is to add the following at line 143 in jquery.autocorrect-1.0.js:

    if((typeof stringToReplace) == 'function') { return; }

  2. EZ September 22, 2011 at 8:40 pm #

    Will this work with contentEditable elements as well as textboxes and textareas?

    • Tarique Sani September 23, 2011 at 8:32 am #

      Try and let us know :-)

      • EZ September 23, 2011 at 8:08 pm #

        It does not work as is. I am making some changes to see if i can get it working...

        • Tarique Sani September 26, 2011 at 9:22 am #

          Thanks for testing - once again let us know if you get it working

Trackbacks/Pingbacks

  1. santhoshtr's status on Tuesday, 30-Jun-09 03:53:31 UTC - Identi.ca - June 30, 2009

    [...] jQuery auto-correct plugin http://www.sanisoft.com/blog/2009/06/22/jquery-auto-correct-plugin/ [...]

  2. A bit of FOSS contribution at Tarique's Travails - June 30, 2009

    [...] jQuery auto-correct plugin – Once attached to an input field of a form this plugin will automatically replace / correct common typos like ‘teh’ and ‘taht’ [...]

Leave a Reply