# Answer Feedback: Javascript bypassed if quote mark in Answer?

**URL:** <https://forums.ankiweb.net/t/answer-feedback-javascript-bypassed-if-quote-mark-in-answer/28741>\
**Category:** Card Design\
**Created:** [March 24, 2023, 11:46pm UTC](https://forums.ankiweb.net/t/answer-feedback-javascript-bypassed-if-quote-mark-in-answer/28741 "2023-03-24T23:46:07Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shell](https://avatars.discourse-cdn.com/v4/letter/s/46a35a/32.png) [@Shell](https://forums.ankiweb.net/u/Shell)\
**Post date:** [March 24, 2023, 11:46pm UTC](https://forums.ankiweb.net/t/answer-feedback-javascript-bypassed-if-quote-mark-in-answer/28741/1 "2023-03-24T23:46:07Z")

</div>

Continuing the discussion from [How to have instant type:answer feedback?](https://forums.ankiweb.net/t/how-to-have-instant-type-answer-feedback/21259/16):

Hi there! The script that provides answer feedback works perfect until I have quotation marks in the Answer field. Normally, as soon as I start typing, the color changes to let me know if I am good so far. However, if there are quote marks in the Answer field, as soon as I start typing the color remains the same. No feedback. Does anyone know why this is happening within Javascript? And, can it be resolved? Thanks!

---

<div class="post-metadata">

**Author:** ![Shell](https://avatars.discourse-cdn.com/v4/letter/s/46a35a/32.png) [@Shell](https://forums.ankiweb.net/u/Shell)\
**Post date:** [March 26, 2023, 3:11pm UTC](https://forums.ankiweb.net/t/answer-feedback-javascript-bypassed-if-quote-mark-in-answer/28741/2 "2023-03-26T15:11:03Z")

</div>

Thank you so much for your solution hkr in the original discussion: [How to have instant type:answer feedback?](https://forums.ankiweb.net/t/how-to-have-instant-type-answer-feedback/21259/16)  
It worked!!

---

<div class="post-metadata">

**Author:** ![kleinerpirat](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/kleinerpirat/32/19863_2.png) [@kleinerpirat](https://forums.ankiweb.net/u/kleinerpirat)\
**Post date:** [March 26, 2023, 5:57pm UTC](https://forums.ankiweb.net/t/answer-feedback-javascript-bypassed-if-quote-mark-in-answer/28741/3 "2023-03-26T17:57:19Z")

</div>

> [@Shell](#):
>
> Does anyone know why this is happening within Javascript?

It has to do with how JavaScript (and any other programming language) is parsed. A quote character like `, " or ’ usually marks the beginning of a string literal. If there’s an opening quote, the next instance of that character will be interpreted as the end of that string literal.

When you got this in your card template:

```auto
var fieldContent = "{{Field}}";

```

… and your field contains a double quote, there will be a syntax error, because all the text after that quote is interpreted as JavaScript. Same goes for ’ and `.

Hikaru’s solution from the other thread avoids this issue, because Anki will not insert the field content directly into your script, but inside an HTML element.

It is the recommended way to make field content available to JavaScript.

---

<div class="post-metadata">

**Author:** ![Shell](https://avatars.discourse-cdn.com/v4/letter/s/46a35a/32.png) [@Shell](https://forums.ankiweb.net/u/Shell)\
**Post date:** [March 27, 2023, 1:02am UTC](https://forums.ankiweb.net/t/answer-feedback-javascript-bypassed-if-quote-mark-in-answer/28741/4 "2023-03-27T01:02:55Z")

</div>

Thank you so much for answering my question. I really appreciate it. 👍

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex002/uploads/anki2/original/1X/8f1279ababc5879d54e4838989f606cfe55af8c7.jpeg) [@system](https://forums.ankiweb.net/u/system)\
**Post date:** [April 26, 2023, 1:03am UTC](https://forums.ankiweb.net/t/answer-feedback-javascript-bypassed-if-quote-mark-in-answer/28741/5 "2023-04-26T01:03:38Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
