I have a login form when I load is I have to click on textbox to type into it. What I want is when page load completed focus should be in username text boxes. How can I do it using javascript?
I have a login form when I load is I have to click on textbox to type into it. What I want is when page load completed focus should be in username text boxes. How can I do it using javascript?
This is quite easy - all you have to do is use the .focus() method. Include a <script> tag immediately after you write your textarea tag like this:
Likewise, you can use it on input fields as well:Code:<textarea id="textbox"></textarea> <script type="text/javascript"> document.getElementById("textbox").focus(); </script>
Make sure you include your <script> tag AFTER your input fields; this is important because you can't call a reference to an object if it doesn't exist, so you must create the object in the first place.Code:<input id="myinput"> <script type="text/javascript"> document.getElementById("myinput").focus(); </script>
Mike
if you wants to focus on the textbox that plese go on coding window in vb.net than write in textbox1.focus
in vb.net we can do it
code:
button_click events
textbox1.text=focus
end sub
to set focus on the paritcular textbox, we have to folle the code :
TextBox1.focus()
this is very easy.
u can do it in following way.
or make separate functionCode:<html> <body onload="document.f1.t1.focus();"> <form name="f1"> <input type="text" name="t1" value=""> <form> </body> </html>
Code:<html> <script language="javascript"> function fun() { document.f1.t1.focus(); } </script> <body onload="fun"> <form name="f1"> <input type="text" name="t1" value="" > <form> </body> </html>
Its pretty simple like what yahoo is doing while you login into their email system. You can easily view their source too.
document.getElementById("inputb").focus();
Hope it helps
Bookmarks