When I print alert
variable valor
I see undefined
.
I tried with document.write
and I get a blank page, I would like to know if someone has had this problem that can help me.
var valor = document.getElementById('nombre').value;
alert(valor.value);
HTML
<div class="col-md-6">
<label>Tu nombre:</label>
<input type="text" name="nombre" id="nombre" class="form-control" onkeypress="return soloLetras(event)">
</div>