</script>
<meta charset="UTF-8">
<input/>
<button>Mostrar texto escrito</button>
<script>
var input = document.querySelector("input");
input.focus();
function mostrarTexto() {
alert(input.value);
input.value = " ";
input.focus();
}
var button = document.querySelector("button");
button.onclick = mostrarTexto;
</script>