I would like to focus on textbox according to their arrangement.... my problem is according to my code it direct focus on third textbox.. but i would like to focus according to arrangement of texbox... example if first textbox is blank then it will focus on first textbox, currently it is focusing on third textbox...
<input type="text" id="txtFirst"/>
<input type="text" id="txtSecond"/>
<input type="text" id="txtThird"/>
<input type="button" onclick="check()" value="Check" />
<script>
function check() {
var err = "";
var first = document.getElementById("txtFirst");
var second = document.getElementById("txtSecond");
var third = document.getElementById("txtThird");
if (first.value == "") {
first.focus();
err = err + "enter the first value";
} if (second.value == "") {
second.focus();
err = err + "enter the second value";
} if (third.value == "") {
third.focus();
err = err + "enter the third value";
} }
</script>