views:

49

answers:

0

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="">

Nevermind, it is the autocomplete that is causing the issue. How can I keep the autocomplete but have the tabs work correctly. E.g. it takes three tabs to move to the next field and not just one.