Ignore Case/Convert to Title Case

150 views Asked by At

For an HTML file that looks like this:

<html>
<head>
</head> 

<body>

<p>
<input type="text" id="textfield">
<input type="button" value="Button" onclick="functionOne()">
</p>

<p id="output"></p>

<script>

    function functionOne() {

    var variableOne = "Yes";
    var variableTwo = document.getElementById("textfield").value;

    if (variableOne.includes(variableTwo) {
       document.getElementById("output").innerHTML = variableOne;
    }


    }

</script>

</body>

</html>

I want to be able to convert my variableTwo to title case (just like how variableOne is) so that I can type something like "yes" or "YES" in the text input box and the if statement would still work. My question is, is there a way to convert to title case? If not, is there a way to just simply ingnore the case when comparing the two strings in the if statement? Thank you.

0

There are 0 answers