I have a JavaScript function that checks the user input and will compare it against the database.
function checkUserInput() {
var userInput = document.getElementById("textInput").value;
var stringToCheckAgainst = random_images_array[num].split('.');
if (userInput == stringToCheckAgainst[0]) {
document.getElementById("row1").innerHTML = "<p>" + txt.fontsize(5) + "</p>";
document.close();
} else {
//user has inputted an incorrect string
document.getElementById("row1").innerHTML = "<p>" + txt1.fontsize(5) + "</p>";
document.close();
}
}
My problem is at the moment this function is case sensitive which means if the user types in “apple” it will return false statements as a fact that all of my objects are named with uppercase letters. How can I make my function not case sensitive to works with both lower case and uppercase letters no matter how the user is typing in?
Aucun commentaire:
Enregistrer un commentaire