I want to perform an action after the user typed in a textbox. I will be using onkeyup
in the textbox.
i want a condition, that will allow the user to perform a task, only if the typed word is a dictionary word or a proper word.
Eg :
- if the user types
hello
, then alert the word Hello. - if the user types
helr
, then alert that this is not a dictionary word.
HTML :
<input type="text" onkeyup="chk();"/>
<span id="indicate"></span>
Javascript :
function chk() {
if(spellcheck()) {
document.getElementById("indicate").innerHTML = "Correct Word";
}
else {
document.getElementById("indicate").innerHTML = "Wrong Word";
}
}
Please Help me defining the function spellcheck()
which will return 1 or 0.
I want this to be performed in client side itself, using javascript.
Thanks in advance.