Check first character of written answer

Dear everyone!

Is there possibility to visual check the first character(s) of written answer?

so far I have this code:

<div class=frontbg><br>

	<div class=backbg>

		{{Back}}

<div class=wordtype><input type="text" id="IdWordtypeClass" onkeyup="countChars(this);">{{type:Front}}</div>

<textarea id="IdTextarea" onkeyup="countChars(this);"></textarea>

<p id="charNum">vysledek</p>
<p id="1.znak">1.znak</p>
<p id="1.znak_odpovedi">1.znak odpovedi</p>

<script>

function countChars(obj){

	var getIdWordtypeClass = document.getElementById("IdWordtypeClass");

	document.getElementById("IdTextarea").innerHTML = getIdWordtypeClass.value;

	var getTextArea = document.getElementById("IdTextarea");


	document.getElementById("1.znak").innerHTML ="{{Front}}".charAt(0);
	document.getElementById("1.znak_odpovedi").innerHTML = getTextArea.value[0];


	if("{{Front}}".charAt(0) == getTextArea.value[0]) 
		{
			document.getElementById("charNum").innerHTML = 'correct';
		}
		else 
		{
			document.getElementById("charNum").innerHTML = 'incorrect';
		}
	}
</script>

The problem is that I can use only textarea to check it, and then I have to copy the same text to {{type:Front}} section and thats quite annoying…

Is there any way? :slight_smile:

Youtube link to presentation of the purpose

No one? :scream:

You can use Anki WebView Inspector to inspect what HTML is generated by {{type:Front}}. That way you can try to add your functionality on top.

2 Likes

thank you for your tip! :star_struck: :+1:

this is my final result: youtube link