HTML/Javascript Strange behavior with input field and TABBING
- by Berlin Brown
I have a strange error where if a user enters in data, say first name and then tabs, the text in the field is highlighted/selected as opposed to moving to the next. So, a person may type the first name and then tab to the next input item, text is selected and then they hit a character and now the name they typed in is deleted.
If I use the default [input] tags, the tab works properly. But in the code below, with keyup, that may change the tabbing behavior.
How can I get my code where it won't select the text. This is replicated in Firefox and Internet Explorer.
function enableSearch(lnameObj) {
var goButtonObj = document.getElementById('goButton');
var nextButtonObj = document.getElementById('nextButton');
var lastName = lnameObj.value;
if (lastName == "") {
goButtonObj.disabled = true;
} else {
goButtonObj.disabled = false;
}
}
<input type="text" size="12" name="lastname" onKeyUp="return enableSearch(this);" value="">