Is there any way to do a Approximate text matching in jquery?
I have a div with the correct answer
<div class="correctAnswer" style="display:none;">CORRECT</div>
and i want that when the answer in the input tag is Approximate correct show some text
<input type="text"> //lets guess i type "CORREC"
<div class="Approximate" style="display:none;">Your answer is Approximate correct!</div>
You could use the Levenshtein Distance algorithm to do so, which will give you a score for the similarity of strings.
It is well described on wikipedia and has been used in a lot of different languages/technologies.
The pseudo algorithm is this:
You may also want to try this javascript implementation on github (which is not mine, BTW).