...

View Full Version : Spell Check Button



lonogod
08-01-2010, 06:24 AM
Hey, everyone! I was wondering if there was anyway to make a spell check button with JavaScript?

I had an idea to disable spell check and then add a button so the user could click it to use spell check...or at least reveal the misspelled words. I'm sure that it's possible. In fact, I have a general idea of how it might be accomplished, but I'm not a JS coder so I don't know exactly how to make it work. Could anyone help, please?

- Lono

Philip M
08-01-2010, 08:52 AM
Google for Javascript Spell Checkers. I don't understand what you mean by "disable spell check".

All these Eastern Europeans who are flocking in - where are they coming from? - Channel Five

lonogod
08-01-2010, 02:02 PM
When I say disable spell check, I mean using the CSS attribute to turn off spell check in a browser (spellcheck="false").

I know about the JS Spell Checker. That's not what I was talking about. Basically, I would have this:


<textarea name="Comments" spellcheck="false"></textarea>
<input type="button" value="Spell Check" onClick="onClickCheck(this)">

That disables the default spell checker in the browser for the text area box. Then I would have something like this (Please, excuse the crudeness and ignorance of this. I am not a JS coder. This will just get my idea across.):


function onClickCheck() {
var sc = textarea.spellcheck
if(sc = "false") {
textarea.spellcheck="true"
}
}

I know that is not even close to accurate JS coding, but it should give an idea of what I'm trying to do. Essentially, the button would re-enable the browser's spell check feature that was disabled by the CSS attribute. I know that seems a bit pointless, but it's something we thought might be a neat feature. Thanks!

- Lono

hdewantara
08-02-2010, 07:39 PM
Helo lonogod,

Spellcheck attribute is part of the new HTML5 spec,
and only few modern browsers support this feature.

My FF could simulate the feature,
but only if I've enabled "Check my spelling as I type" option:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta content="text/html; charset=utf-8" http-equiv="content-type" />

<script type="text/javascript">
//<![CDATA[
function is_checked(el){
document.getElementById("ta").spellcheck = el.checked;
}
//]]>
</script>

</head>

<body>
<textarea id="ta" spellcheck="false"></textarea>
<br /><span>spellcheck</span>
<input type="checkbox" onclick="is_checked(this)" />
</body>

</html>


Hendra

lonogod
08-03-2010, 01:53 AM
This is what I was trying to do.

<html>
<head>

<script language="JavaScript">
function onClickCheck() {
var sc = document.getElementsByName('Comments')[0];
if(!sc.spellcheck) {
sc.spellcheck = "true";
}
}
</script>

</head>
<body>

<form method="post">
<textarea name="Comments" spellcheck="false"></textarea><br>
<input type="button" value="Spell Check" onClick="onClickCheck()">
</form>

</body>
</html>
Obviously it only works when the user has that feature enabled on their browser and only if the browser has a built in spell check function. Feel free to use this if you need it anyone! Thanks for everything!

- Lono



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum