T
Teach
I am designing a small quiz, and everything works just fine except one
small problem. If a user inputs any uppercase letters at all, the
check function marks the response incorect. Below is the snippet of
code for the function check. Can anyone tell me how to modify it to
ignore "case". The user needs to be able to input in both upper and
lower case.
Thanks in advance. Here is the snippet of code:
function check(){
for(i=0;i<answer.length;i++){
if(document.myform.elements.value.toLowerCase()==answer){
score++;
}else{
if(document.myform.elements.value!=""){
document.myform.elements.value="";
}
}
}
alert(score + " out of " + answer.length + ".");
score = 0;
}
//Put the correct answers into all the fields
function show(){
for(i=0;i<answer.length;i++){
document.myform.elements.value = answer;
}
}
small problem. If a user inputs any uppercase letters at all, the
check function marks the response incorect. Below is the snippet of
code for the function check. Can anyone tell me how to modify it to
ignore "case". The user needs to be able to input in both upper and
lower case.
Thanks in advance. Here is the snippet of code:
function check(){
for(i=0;i<answer.length;i++){
if(document.myform.elements.value.toLowerCase()==answer){
score++;
}else{
if(document.myform.elements.value!=""){
document.myform.elements.value="";
}
}
}
alert(score + " out of " + answer.length + ".");
score = 0;
}
//Put the correct answers into all the fields
function show(){
for(i=0;i<answer.length;i++){
document.myform.elements.value = answer;
}
}