Senha e Password Div

O

by thvinic

HTML

<input type="text" id="password">
<br>
<input id="button" type="button" value="Login">



<div id="HIDDENDIV" class="hidden">lorem ipsum,lorem ipsum,lorem ipsum,lorem ipsum,lorem ipsum,lorem ipsum,lorem ipsum,lorem ipsum,lorem ipsum</div>

CSS

.hidden { display: none; }

ofusque este css

JavaScript

// Get references to the elements you'll be working with
var input = document.getElementById("password");
var div = document.getElementById("HIDDENDIV");
var btn = document.getElementById("button");

// Set up event handlers in JavaScript
button.addEventListener("click", validate);

function validate(){
  if (input.value == '12345') { 
     // No need to add a "show" class. Just remove the "hidden" class.
     div.classList.remove('hidden');
     
     // Or, add it:
     input.classList.add("hidden");
  } else {  
     password.focus(); // <-- If you don't do this first, your select code won't work
     password.setSelectionRange(0, password.value.length);   
     alert('incorrect password!'); 
  }
}

input.addEventListener("keydown", function(event){
 if (event.keyCode === 13){
   // No reason to simulate a button click. Just call the code that needs to be run.
   validate();
 }

});
[17/1 10:28] Thiago Vinic: // No need to add a "show" class. Just remove the "hidden" class.
     div.classList.remove('hidden');
     localStorage.setItem('hiddenValue', div.innerHTML);
function setupPage() {
  if (localStorage.getItem('hiddenValue')) {
    input.classList.add('hidden');
    btn.classList.add('hidden');
    div.classList.remove('hidden');
  }
}