
There are several example templates and associated JavaScript library files located in the spellchecker directory.
Checking one or more textareas by argument (spellchecker/example.cfm):
<html>
<head>
<script language="JavaScript" src="spell.js"></script>
<title>Spell Checker Test Page</title>
</head>
<body>
<form name="myForm">
<textarea name="content" rows="14" cols="45">I am speled wrang</textarea><br>
<textarea name="content2" rows="14" cols="45">I am aalso spelled wrang</textarea>
<input type="button" value="Check Spelling" onClick="spell('document.myForm.content.value', 'document.myForm.content2.value')">
</form>
</body>
</html>
Spell Checking all textareas with a single button (spellchecker/example2.cfm):
<html> <script language="JavaScript" src="spellAll.js"></script>
</head>
<head>
<title>Spell Checker Test Page</title>
<body>
<form name="myForm">
<textarea name="content" rows="14" cols="45">I am speled wrang</textarea><br>
<textarea name="content2" rows="14" cols="45">I am aalso spelled wrang</textarea>
<input type="button" value="Check Spelling" onClick="spell()">
</form>
</body>
</html>
The spellAll.js library finds all textareas in the example above and sends references to the Foundeo Spell Checker object. (lines 23 - 30 of spellAll.js)
Spell Checking from form validation (spellchecker/example3.cfm):
<html>
<head>
<script language="JavaScript" src="spellInValidation.js"></script>
<script language="JavaScript">
function validation() {
// Cancel the submit event
window.event.returnValue = false;
// Sample validation
if(myForm.content == "") {
alert("Please enter some text.");
myForm.content.focus();
return false;
} else {
spell('myForm');
}
}
</script>
<title>Spell Checker Test Page</title>
</head>
<body>
<form name="myForm" action="myPage.cfm" method="post" onSubmit="validation()">
<textarea name="content" rows="14" cols="45">I am speled wrang</textarea><br>
<textarea name="content2" rows="14" cols="45">I am aalso spelled wrang</textarea>
<input type="submit" name="formButton" value="Save">
</form>
</body>
</html>
When spell checking from form validation, the submit event is cancelled to prevent the form from submitting before spell checking is complete. The form name is passed to the spell() function and used to submit the form after spell checking.
If the name of your submit button is "submit", an Object does not support property or method error is returned.
Spell Checking multiple ActivEdit instances when a form is submitted (spellchecker/example4.cfm):
<html>
<head>
<title>Spellchecking Multiple ActivEdit fields on Submit</title>
<!-- Import the library to spellcheck multiple ActivEdit instances. -->
<script language="JavaScript" src="/spellchecker/spellAE.js"></script>
</head>
<script>
function validate() {
spell();
return false;
}
function registerListener() {
document.testForm.onsubmit = validate;
}
</script>
<body onLoad="registerListener()">
<form name="testForm" id="testForm" action="displayPage.cfm" method="post">
Title:<input type="title" name="test" size="20"><br><br>
<cf_activedit
name="field1"
inc="inc/">
This is speled wrang.
</cf_activedit>
<cf_activedit
name="field2"
inc="inc/">
This is aalso speled wrang.
</cf_activedit>
<br><br>
<input type="submit" name="submitButton" value="Save Event">
</form>
</body>
</html>
Adjust the inc value for the example above to reflect the location of your inc directory. In the example above, all ActivEdit instances are detected in the JavaScript library file, spell checked, and then the content is moved to ActivEdit's hidden textareas with the call to ae_onSubmit() and the form is submitted.
The form name is passed to the spell() function, as in the form validation example for textareas.
Spell checking with the spellcheck button on the ActivEdit toolbar (spellcheck/example5.cfm):
If you've used Foundeo Spell Checker with ActivEdit in the past, the CFX tag will continue to work by adding spellcheck to the toolbar attribute of ActivEdit, but there may be some cases where you may want to use Foundeo Spell Checker 2.0 with ActivEdit, such as when you want to use the new addLexicon() method to extend a language or create multilingual spelling sessions. Foundeo Spell Checker 2.0 is also faster.
<html>
<head>
<title>Using Foundeo Spell Checker 2.0 with the spellcheck button in ActivEdit</title>
<!-- Import the library to spellcheck multiple ActivEdit instances. -->
<script language="JavaScript" src="/spellchecker/spellButton.js"></script>
<!-- Override ae_spellcheckwin -->
<script language="JavaScript">
function aeapi_local_onLoad(aeObject, fieldname) {
ae_spellcheckwin = function(num) {
spell(num);
}
}
</script>
</head>
<body>
<form name="testForm" id="testForm" action="displayPage.cfm" method="post">
Title:<input type="title" name="test" size="20"><br><br>
<cf_activedit
name="field1"
inc="inc/"
toolbar="spellcheck">
This is speled wrang.
</cf_activedit>
<br><br>
<input type="submit" name="submitButton" value="Save Event">
</form>
</body>
</html>
For this example, we include the new library and override the existing ae_spellcheckwin() function when an ActivEdit instance is initialized through the ActivEdit API.