Surely this must be straightforward...
I want to enable a button only if text has been entered into a text box. I don't want to use the onchange event as my user may not tab out of the box and may just key some text and then use the mouse to press the button, in which case the onchange event will not be triggered. I have tried onkeypress, onkeyup but these all seem to trigger before the text has been entered and therefore the text box value is still blank.
Basic JS code to enable/disable the button currently looks like:
But what event will successfully trap this?
Cheers
I want to enable a button only if text has been entered into a text box. I don't want to use the onchange event as my user may not tab out of the box and may just key some text and then use the mouse to press the button, in which case the onchange event will not be triggered. I have tried onkeypress, onkeyup but these all seem to trigger before the text has been entered and therefore the text box value is still blank.
Basic JS code to enable/disable the button currently looks like:
Code:
function edit1_onkeyup(){
if(document.getElementByID('edit1').value != ''){
document.getElementByID('button1').disabled = false
} else {
document.getElementByID('button1').disabled = true
}
But what event will successfully trap this?
Cheers
