vinay singh

vinay singh

  • NA
  • 0
  • 1.1k

Make Focus On Text box by using javascript.

Nov 10 2009 2:00 AM
Hi,
I am working on a project in which there are two textbox one for user id and other for password.
The requirement is that if user enter incorrect user id on that case focus goes to user id text field and if user enters correct user id and wrong password in that case it should show focus on password box.

i have written the below code:

if(objXMLHttp_Login.responseXML.getElementsByTagName(string)[0].childNodes[0].nodeValue == 2)
       {
           alert(Incorrect E-mail address, user does not exist.);
           document.all(txt_username).focus();
               document.getElementById(txt_password).value="";
               document.getElementById(txt_username).value="";
               document.getElementById(div_pre_login).style.display = '';
           }
           else if(objXMLHttp_Login.responseXML.getElementsByTagName(string)[0].childNodes[0].nodeValue == 0)
       {
           alert(Incorrect Password.);
           document.getElementById(div_pre_login).style.display = '';
             document.all.item('txt_password').focus();
               document.getElementById(txt_password).value="";
       }  

Thanks & Regards
Vinay Singh

Answers (4)