Jump to content

Question about a login?


keystroke

Recommended Posts

You know when you login to a website, lets say face book for example. When you get to the site you do not need to click in the username field. You can just start typing your username in right away, without using your mouse to click where you want to type. I want this implemented into my site, just not sure how to go about it. I have tried searching google many times with no luck as of yet.

Link to comment
https://forums.phpfreaks.com/topic/154454-question-about-a-login/
Share on other sites

This is done using javascript.

 


<script type="text/javascript">

var field1 = document.getElementById('fieldname');
var field2 = document.getElementById('field2name');

function focusLoad(){

if (field1.value.length == 0)
{
field1.focus();
}
else
{
field2.focus();
}

}
</script>

<body onload="focusLoad();">

 

That should do the job in most browsers, look on the W3C schools website to look into javascript nd the HTML DOM more.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.