HTML/Javascript Strange behavior with input field and TABBING
        Posted  
        
            by Berlin Brown
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Berlin Brown
        
        
        
        Published on 2010-05-20T18:56:37Z
        Indexed on 
            2010/05/20
            19:00 UTC
        
        
        Read the original article
        Hit count: 284
        
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="">
© Stack Overflow or respective owner