I'd like to make a webpage with text box without button. If i type couple of letters and push button 'Enter', comes after 1 second alert dialog box with text from text box. Everything works correct, only that aler dialog box doesn`t come after Enter, but after mouse click.
<!Doctype HTML!>
<html>
<head>
<meta charset="utf-8">
<head>6-4</head>
<script>
var keyCode = '';
var naam = '';
window.onload = function () {
var divResult = document.getElementById('divResult');
document.getElementById('txtInput').addEventListener('blur', function () {
naam = document.getElementById('txtInput').value;
document.getElementById('txtInput').onkeyup = function (e) {
keyCode = e.keyCode;
if (keyCode === 13) {
}
};
setTimeout("alert(naam);", 1000);
}, false);
};
function stopAlerts() {
clearInterval(txtNaam);
}
</script>
</head>
<body>
<h2>Type some letters in text box and push 'Enter'</h2>
<input type="text" id="txtInput" value="" />
<div id="divResult"></div>
</body>
</html>