I have 2 textboxes. If the first textbox is empty it cannot proceed to the 2nd textbox when I hit tab or the user will intentionally place the focus on the 2nd textbox.

**html**

```
<input type="text" id="txt1" />
<input type="text" id="txt2" />

```

**jquery/javascript**

```
$("#txt1").keydown(function (e) {
    if (e.which == 9)  {
        if ($.trim($(this).val() == ""))
            $(this).focus();
     }
 });

if ($("#txt2").is(":focus")) {
    if ($.trim($("#txt1").val() == "")) 
         $("#txt1").focus();
}

```

Please see the this : <http://jsfiddle.net/N8GAr/>

I need help with this. Thanks.