0

I'm brand new to html and JavaScript, I have this function on a button and I want the script to change my label to "Correct password" when the value of the input box is "greenapples42" It always says correct no matter what the input is though.

function Gen() {
  var Val = document.getElementById("Pass").value
  var SpecPass = "greenapples42"
  if (Val = SpecPass) {
    document.getElementById("Label1").textContent = "Correct password"
  } else {
    document.getElementById("Label1").textContent = "Incorrect password"
  }
}
<label for="Pass" id="Label1"></label>
<input type="text" name="varTest" id="Pass" value="">
<button onclick="Gen()" style="border: 3px double black; background-color:lightblue">Check</button>
j08691
  • 204,283
  • 31
  • 260
  • 272
Jcat710
  • 1
  • 1

0 Answers0