I need some help with a part of my program which is suppose to time out. I have a key pad which allows 4 digits to be input then passes this code to another function. I needed a timer after the 4th digit for 1 second so the page will display the result before sending the key and clearing the screen. This is the original part that works.
setTimeout(alarm,1000);
but when I add the function to send the key it stops working
if(code.value.length == 4){
document.getElementById("message").style.display = "block";
setTimeout(alarm(code.value),1000);
}
}
function alarm(code){
alert(code);
emptyCode();
}
I have read that I cannot put a function within the timeout script so is there another way to do this