# Instant Type Answer Feedback - problem and fix

**URL:** <https://forums.ankiweb.net/t/instant-type-answer-feedback-problem-and-fix/49076>\
**Category:** Card Design\
**Created:** [September 6, 2024, 2:29am UTC](https://forums.ankiweb.net/t/instant-type-answer-feedback-problem-and-fix/49076 "2024-09-06T02:29:23Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Keks](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/keks/32/20537_2.png) [@Keks](https://forums.ankiweb.net/u/Keks)\
**Post date:** [September 6, 2024, 2:13pm UTC](https://forums.ankiweb.net/t/instant-type-answer-feedback-problem-and-fix/49076/2 "2024-09-06T14:13:05Z")

</div>

> [@How to have instant type:answer feedback?](https://forums.ankiweb.net/t/how-to-have-instant-type-answer-feedback/21259/14):
>
> Hey, some of use want a shot at coding stuff for free as well. Just kidding, but to answer your request, and since Matthias has already done the heavy lifting, this is an easy fix. You don’t even need to compare substrings anymore. JS: \<script\> (() =\> { /\*\* \* Type-in-the-answer live feedback for Anki (vague variant) \* @author Matthias Metelka | @kleinerpirat \*/ const input = document.getElementById("typeans"); const answer = "{{Answer}}"; if (input) { input.add…

The template works on ankidroid. I use all the suggested fixes and improvements suggested by users.

> **Summary**
>
> ```auto
> {{type:Word}}
> <div id="answer-field" hidden>{{Word}}</div>
> 
> <script>
> (() => {
> /**
> * Type-in-the-answer live feedback for Anki (vague variant)
> * @author Matthias Metelka | @kleinerpirat
> */
> const input = document.getElementById("typeans");
> const answer = document.getElementById("answer-field").innerHTML;
> if (input) {
> input.addEventListener("input", () => {
> input.classList.add("typed");
> input.classList.toggle(
> "goodsofar",
> input.value == answer.substring(0, input.value.length)
> );
> input.classList.toggle(
> "correct",
> input.value == answer
> );
> });
> }
> })();
> </script>
> 
> ```

> **Summary**
>
> `{{type:Word}}`

> **Summary**
>
> ```auto
> #typeans.typed {
> 
> background: red;
> 
> }
> 
> #typeans.typed.goodsofar {
> 
> background: yellow;
> 
> }
> 
> #typeans.typed.correct {
> 
> background: green;
> 
> }
> 
> ```

---

_[View the full topic](https://forums.ankiweb.net/t/instant-type-answer-feedback-problem-and-fix/49076)._
