Hello, how to know the length of an input in Javascript
alert("Size: "+document.getElementById('champ').length)
not work undefined
Hello, how to know the length of an input in Javascript
alert("Size: "+document.getElementById('champ').length)
not work undefined
alert("Size: "+document.getElementById('champ').value.length)
You have to pluck the "value" attribute from the DOM element, and get the length of that.
<input type='text' id='champ' length=3 value="ab">
document.getElementById("champ").getAttribute("length")
//returns 3
document.getElementById("champ").value.length
//returns 2