I will flash a scrambled word and then the user will type in what the scrambled word is.
So far I have this code. This is for shuffle and display.
document.getElementById("shuffle").value = shuffle(document.getElementById("word").value);
var shuffledword = document.getElementById("shuffle").value;
var z = shuffledword.split("").join(' ');
var x=document.getElementById("demo");
x.innerHTML=z;
var str=document.getElementById("demo").innerHTML;
var n=str.replace(charcode,"...");
document.getElementById("demo").innerHTML=n;
What I want is to restrict the user to input the same number letters as in the shuffled word. Example: the word is “DOOMED”; I want to make it so that the user cannot click the letter D and O three times, but only once or twice. Same for the other letters, depending on the number letters in the shuffled word.
It this possible?
edit Added
return true / falsein process_user_char to integrate into onkeypressed.Here is the jsfiddle.