When using JavaScript SpellCheck we can easily target one, many or all field on the page using our unique field selectors.
This methodology applies to the following functions:
Wherever the "Fields" parameter is passed to JavaScriptSpellCheck - you can pass the following
arguments:
To select 1 Field by its id
Pass the Id as a string. This can also spellcheck any HTML element's innerHTML. e.g.
$Spelling.SpellCheckInWindow('myTextArea1')
To select multiple Fields
Use a comma to separate Ids, or alternatively you can pass an array
$Spelling.SpellCheckInWindow('myTextArea2,myInput')
To select a Field by its JavaScript DOM object reference
Simply send the DOM object into the function:
$Spelling.SpellCheckInWindow(document.getElementById('myTextArea2'))
or multiple objects as an array:
$Spelling.SpellCheckInWindow([document.getElementById('myTextArea1'),document.getElementById('myTextArea2')])
To select field by their by its CSS Class
Set fields to ".MyClassName" and all textareas and input with that class name will be affected.
''$Spelling.SpellCheckInWindow('.MyClassName')
To select ALL viable fields
Just set Fields to "all"
$Spelling.SpellCheckInWindow('all')
To select all Textareas
Just set Fields to "textareas"
$Spelling.SpellCheckInWindow('textareas')
To select all text inputs
To select all inputs to type "text" just set Fields to "textinputs"
$Spelling.SpellCheckInWindow('textinputs')
To select all enabled fields
To select all inputs and textareas that are enabled and bot read-only just set Fields to "enabled"
$Spelling.SpellCheckInWindow('enabled')
To select all rich HTML editors on the page fields
Just set Fields to "editors". Learn more about spell-checking of rich HTML editors..
$Spelling.SpellCheckInWindow('editors')
<script type='text/javascript' src='/JavaScriptSpellCheck/include.js' ></script> <script type='text/javascript'>$Spelling.SpellCheckAsYouType('all') //all viable fields</script> <textarea name="myTextArea1" id="myTextArea1" cols="30" rows="4" class="SpellMe">Hello Worlb.</textarea> <textarea name="myTextArea2" id="myTextArea2" cols="30" rows="4">Hello Worlb.</textarea> <input type='text' value='Hello worb' name="myInput" id='myInput' /> <h6>With all JavaScriptSpellCheck functions you can pass the following parameters to select 'Fields':</h6> An Id: <input type="button" value="'myTextArea1'" onclick="$Spelling.SpellCheckInWindow('myTextArea1')"><br/> Comma Separated Ids:<input type="button" value="myTextArea2,myInput'" onclick="$Spelling.SpellCheckInWindow('myTextArea2,myInput')"><br/> An Array:<input type="button" value="['myTextArea1','myTextArea2'])" onclick="$Spelling.SpellCheckInWindow(['myTextArea1','myTextArea2'])"><br/> A DOM Object:<input type="button" value="document.getElementById('myTextArea2')" onclick="$Spelling.SpellCheckInWindow(document.getElementById('myTextArea2'))"><br/> A CSS Class preceded by a dot:<input type="button" value=".SpellMe" onclick="$Spelling.SpellCheckInWindow('.SpellMe')"><br/> "all":<input type="button" value="'all'" onclick="$Spelling.SpellCheckInWindow('all')"><br/> "enabled":<input type="button" value="'enabled'" onclick="$Spelling.SpellCheckInWindow('enabled')"><br/> "textareas":<input type="button" value="'textareas'" onclick="$Spelling.SpellCheckInWindow('textareas')"><br/> "textinputs":<input type="button" value="'textinputs'" onclick="$Spelling.SpellCheckInWindow('textinputs')"><br/> "editors":<input type="button" value="'editors'" onclick="$Spelling.SpellCheckInWindow('editors')"> </body> </html>
Function | Description | Example |
---|---|---|
$Spelling.SpellCheckInWindow(Fields) | Opens a spellchecking dialog window
|
Live Demo With Source Code... |
$Spelling.SpellCheckAsYouType(Fields) | Causes any texarea(s) to underline any misspelled words - and provides spelling suggestions on
right click.
|
Live Demo With Source Code... |
$Spelling.LiveValidation(Field,MessageElementId) | Shows a warning message beside Field when it contains spelling errors.
|
Live Demo With Source Code... |
Function | Description | Example |
---|---|---|
$Spelling.BinSpellCheck(input) | Returns bool:
| Live Demo With Source Code... |
$Spelling.BinSpellCheckFields(Fields) | Spell checks one or more fields in your page - and returns bool:
| Live Demo With Source Code... |
$Spelling.SpellCheckSuggest(input) | Returns an array of spelling suggestions for input. | Live Demo With Source Code... |
$Spelling.ListDictionaries() | Returns an array of currently installed dictionaries in your JavaScriptSpellCheck/dictionaries folder. | Live Demo With Source Code... |
Function | Description | Example |
---|---|---|
o = $Spelling.AjaxSpellCheck(input);
o.onSpellCheck = function(result,suggestions){} | Spellchecks a word and asynchronously returns a boolean spellchecking result and suggestions. | Live Demo With Source Code... |
o = $Spelling.AjaxSpellCheckFields(Fields)
o.onValidate = function(result){} | Spell checks one or more fields in your page - and returns asynchronously a boolean spellchecking result. | Live Demo With Source Code... |
o = $Spelling.AjaxDidYouMean(string)
o.onDidYouMean = function(result){} | Asynchronously returns an suggestions string for a search box spellchecking phrase. | Live Demo With Source Code... |
Property | Type | Default Value | Description |
---|---|---|---|
$Spelling.DefaultDictionary | string | "English (International)" | The dictionary language used by JavaSript SpellCheck.
|
$Spelling.UserInterfaceTranslation | string | "en" | Translates the context menu and spellchecker dialog into over 50 international languages.
|
$Spelling.ShowStatisticsScreen | bool | false | Shows a statistics screen (word count, edit count) after SpellCheckInWindow. |
$Spelling.SubmitFormById | string | "" | Will submit a form (identified by its id attribute) once spellchecking once SpellCheckInWindow is complete. |
$Spelling.Theme | string | "js.modern" | Allows you to apply a CSS theme to change the appearance of JavaScript SpellCheck.
|
$Spelling.CaseSensitive | bool | true | Spellchecker notices cAse mIstAkes |
$Spelling.IgnoreAllCaps | bool | true | Spellchecker ignores BLOCK CAPITAL letters which are often acronyms. |
$Spelling.CheckGrammar | bool | true | Spellchecker notices basic grammar mistakes such as sentence casing and repeated words. |
$Spelling.IgnoreNumbers | bool | true | Spellchecker ignores words with numbers in them like "High5" or "MSO7262BGO" |
$Spelling.ShowThesaurus | bool | true | Spellchecker shows a thesaurus and look-up-meaning link during SpellCheckInWindow |
$Spelling.ShowLanguagesInContextMenu | bool | false | Allows the user to pick a dictionary Language from all installed dictionaries during SpellCheckAsYouType |
$Spelling.ServerModel | string | "auto" | Allows you to pick which server model JavaScriptSpellCheck will use for its AJAX requests. Values available are:
|
$Spelling.PopUpStyle
| string | "modal" | SpellCheckInWindow pop-up style:
See the custom PopUps And Themes Tutorial.
|
Event | Description | Example |
---|---|---|
onDialogOpen() | SpellCheckInWindow dialog pops up. | $Spelling.PopUpStyle="modeless";
o = $Spelling.SpellCheckInWindow('all'); |
onDialogComplete() | SpellCheckInWindow dialog completes successfully - user has not quit | $Spelling.PopUpStyle="modeless";
o = $Spelling.SpellCheckInWindow('all'); |
onDialogCancel() | SpellCheckInWindow dialog completes is quite by the user | $Spelling.PopUpStyle="modeless";
o = $Spelling.SpellCheckInWindow('all'); |
onDialogClose() | SpellCheckInWindow dialog closes for any reason | $Spelling.PopUpStyle="modeless";
o = $Spelling.SpellCheckInWindow('all'); |
onChangeLanguage(language) | SpellCheckInWindow or SpellAsYouType language is changed by the user.
| $Spelling.PopUpStyle="modeless";
o = $Spelling.SpellCheckInWindow('all'); |
onIgnore(word) | A word is ignored by the user in wither SpellCheckInWindow or SpellAsYouType.
| $Spelling.PopUpStyle="modeless";
o = $Spelling.SpellCheckInWindow('all'); |
onIgnoreAll(word) | The user clieck 'Ignore All' for a word in either SpellCheckInWindow or SpellAsYouType.
| $Spelling.PopUpStyle="modeless";
o = $Spelling.SpellCheckInWindow('all'); |
onChangeWord(from,to) | The user changes a word in either SpellCheckInWindow or SpellAsYouType.
| $Spelling.PopUpStyle="modeless";
o = $Spelling.SpellCheckInWindow('all'); |
onChangeAll(from,to) | The user clicks 'Change All' for a word in SpellCheckInWindow.
| $Spelling.PopUpStyle="modeless";
o = $Spelling.SpellCheckInWindow('all'); |
onLearnWord(word) | The user "Adds to Dictionary" in either SpellCheckInWindow or SpellAsYouType.
| $Spelling.PopUpStyle="modeless";
o = $Spelling.SpellCheckInWindow('all'); |
onLearnAutoCorrect(from,to) | The user adds to autocorrect in SpellCheckInWindow.
| $Spelling.PopUpStyle="modeless";
o = $Spelling.SpellCheckInWindow('all'); |
onUpdateFields(arrFields) | Any field is updated due to spellchecing.
| $Spelling.PopUpStyle="modeless";
o = $Spelling.SpellCheckInWindow('all'); |
JavaScriptSpellCheck also provides a jQuery SpellCheck Plugin
jQuery Functions
Function | Return Value | Description |
---|---|---|
$('#mySelction').spellCheckInDialog(options) | Opens a spellchecking dialog window | Spelling Instance Object
|
$('#mySelction').spellAsYouType(options) | Spelling Instance Object | Causes any texarea(s) selected to underline any misspelled words - and provides spelling suggestions on right click.
|
$('#mySelction').binSpellCheckFields(options) | *True if all fields are spelled correctly
| Spell checks all field in the selection.
|
jQuery Options
Option | Default Value | Description |
---|---|---|
defaultDictionary | "English (International)" | Default dictionary the spell checker will use.
|
userInterfaceTranslation | "en" | Translates the spellchecker dialog into over 50 international languages automatically. |
showStatisticsScreen | true | Shows statistics such as word count and number of edits after spellCheckInDialog is complete. |
submitFormById | "" | javascript id of a form to submit after spellCheckInDialog is complete. |
theme | "modern" | CSS theme to apply to the spellchecker.
|
caseSensitive | true | Catches spelling mistakes caused by iNcoorect CasIng. |
checkGrammar | true | Catches basic grammar mistakes such as repeated words, sentence casing and punctuation |
ignoreAllCaps | true | Ignores BLOCK CAPS which are often abbreviations or product codes. |
ignoreNumbers | true | Ignores w0rds w1th num8rs in them which are often product codes. |
showThesaurus | true | Shows a thesaurus and word meaning lookup during spellCheckInDialog |
showLanguagesInContextMenu | true | Allows the user to change dictionary 'on the fly' when using spellAsYouType |
serverModel | "auto" | Chooses the server model that does the 'behind the scenes' AJX spellchecking requests. We support:
|
popUpStyle | "auto" | spellCheckInDialog pop-up style:
See the customPopUps And Themes Tutorial. |