Estoy tratando de comprobar simplemente si tengo un cuadro de texto de entrada vacío pero me sale este error cuando ejecuto esto en cromo:No se puede leer la longitud característica de indefinido
Uncaught TypeError: Cannot read property 'length' of undefined.
Aquí es cómo van haciendo sobre él . Compruebo la disponibilidad de DOM y luego llamo a la función.
function walkmydog() {
//when the user starts entering
if(document.getElementById('WallSearch').value.length == 0) {
alert("nothing");
}
}
if (document.addEventListener) {
document.addEventListener("DOMContentLoaded", walkmydog, false);
}
¿Se puede adjuntar la parte pertinente de su HTML? –
¿Estás seguro de que 'WallSearch' es la ID del elemento' input'? Si lo fuera, no obtendría ese error: http://jsfiddle.net/fkling/x9Vf2/ –
¿Cómo verifica la disponibilidad de DOM? – bjornd