I have an easy password box shake animation when the password is wrong but it doesn't play for the second time when I enter the wrong password. My logic is the following:
function passwordCheck(){
var password = document.getElementById("passwordbox")
var checkbox = document.getElementById("checkbox")
var submittedPassword = password.value;
if( submittedPassword == "abc"){
location.href = "secret.html"
}
if(submittedPassword !== "abc"){
checkbox.checked = false
document.getElementById("passwordbox").style.animation = "shake 0.82s cubic-bezier(.36,.07,.19,.97) both"
}
}
This is my css animation:
@keyframes shake {
8%, 41% {
transform: translateX(-10px);
}
25%, 58% {
transform: translateX(10px);
}
75% {
transform: translateX(-5px);
}
92% {
transform: translateX(5px);
}
0%, 100% {
transform: translateX(0);
}
}