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
Loading
Sriram RamaniPosted Nov 10, 2009, 3:40 AM
Nilanka DharmadasaPosted Nov 10, 2009, 3:20 AM
document.formname.elements[ i ].focus()
Here i is the index of the control.
Posted Nov 10, 2009, 2:20 AM
As u said user .focus();
but it's not working. it's giving error
.focus is not a method.
Regards
vinay
Nilanka DharmadasaPosted Nov 10, 2009, 2:14 AM
You can set the focus using following code.
document.getElementById(txt_password).focus()
For the username also u can use the same way.
If this helps please accept my answer.