I want to focus on the textbox according to their arrangement .... My problem is that according to my code it Focus third textbox .. But I want to focus according to the arrangement of the Texbox ... Example If the first textbox is empty then it will first focus on the textbox, it currently focuses on the third textbox Endrit is ...
& lt; Input type = "text" id = "txtFirst" /> & Lt; Input type = "text" id = "txtSecond" /> & Lt; Input type = "text" id = "txtThird" /> & Lt; Input type = "button" onclick = "check ()" value = "check" /> & Lt; Script & gt; 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 another value"; } If (third. Value == "") {third. Focus (); Err = err + "Enter the third value"; }} & Lt; / Script & gt;
When you check, you need more statements like this. .
if (first.value == "") {first.focus (); Err = err + "Enter the first value"; } And if (second.value == "") {second.focus (); Err = err + "Enter another value"; } And if (third. Value == "") {Third. Focus (); Err = err + "Enter the third value"; }
No comments:
Post a Comment