Question Relates Javascript Could Please Show Code Working Want Create 2 Text Boxes User E Q43802357
This question relates to Javascript.
Could you please show me why my code is not working? I want tocreate 2 text boxes and have the user enter something into both ofthem. If the text entered into both boxes is identical the a greenmessage is made visible. If the boxes are different a red messageis made visable. Please keep it simple because I am new tojavascript.
<html>
<head>
<title></title>
<script>
function boxTest(){
var text1 =document.getElementById(“box1”);
var text2 =document.getElementById(“box2”);
if(text1==text2){
document.getElementById(“greenText”).innerHTML.style.visibility=”visible”;
}
else{
document.getElementById(“redText”).innerHTML.style.visibility=”visible”;
}
}
</script>
</head>
<body>
<h1 style=”color:blue”>Inputsome text into each box</h1>
<input id=”box1″type=”text”>
<input id=”box2″type=”text”>
<input id=”submit”onClick=”boxTest()” type=”submit” value=”submit”>
<h1 id=”greenText”style=”color:green;visibility: hidden”>”Match!”</h1>
<h1 id=”redText”style=”color:red;visibility:hidden”>”Mismatch!”</h1>
</body>
</html>
Expert Answer
Answer to This question relates to Javascript. Could you please show me why my code is not working? I want to create 2 text boxes …
OR