morning!
i want to run a javascript function when I enter a key in a form text input by using onKeyDown
everything runs perfectly except the function only executes after the 2nd key stroke (not 1st key stroke, as I would expect it to)
maybe onKeyDown isn't the appropriate event or maybe i am doing something else wrong?
here's my html bit
and here's the javascript
i want to run a javascript function when I enter a key in a form text input by using onKeyDown
everything runs perfectly except the function only executes after the 2nd key stroke (not 1st key stroke, as I would expect it to)
maybe onKeyDown isn't the appropriate event or maybe i am doing something else wrong?
here's my html bit
Code:
<input type="text" name="dogname2" class="formtextinput" id="inputter" onKeyDown="hidecontent(brad)" onBlur="unhidecontent(this)" /> <span id="brad"> Bradd </span>
Code:
function hidecontent(el) {
var elementcontent = document.getElementById("brad")
var inputtercontent = document.getElementById("inputter")
if (inputtercontent.value!="") elementcontent.style.cssText = "visibility:hidden"
}
function unhidecontent(el) {
var elementcontent = document.getElementById("brad")
if (el.value=="") elementcontent.style.cssText = "visibility:normal"
}
Comment