Automatic focus on username field when logging in

Suggestions or questions relating to The Greenhouse

Moderator: GH Moderators

Post Reply
User avatar
zim
Laurie Daley
Posts: 10639
Joined: July 8, 2015, 3:38 pm
Favourite Player: NRL: Joseph Tapine
NRLW: Grace Kemp
Location: Sydney

Automatic focus on username field when logging in

Post by zim »

Please can you update your function that runs when logging in that automatically focusses the username field.
It runs on window load so by then I've already filled out the username and am halfway through my password before it flicks the cursor back to the username field.

This point would be moot if it automatically logged me in each time but it never remembers to.

The function is:

Code: Select all

onload_functions.push('document.getElementById("username").focus();');
It needs to be updated to:

Code: Select all

function someFunction(){
    var elemUsername = document.getElementById("username");
    
    if(elemUsername.value === ''){
        elemUsername.focus();
    }
}


onload_functions.push(someFunction);
Or if you need it in a string on one line:

Code: Select all

onload_functions.push('var elemUsername = document.getElementById("username"); if(elemUsername.value === "")elemUsername.focus();')
User avatar
greeneyed
Don Furner
Posts: 145091
Joined: January 7, 2005, 4:21 pm

Re: Automatic focus on username field when logging in

Post by greeneyed »

Maybe Skeepe can help. If you're having trouble staying logged in, however, bookmark this URL and log in via this URL: index.php
Image
The Nickman
Mal Meninga
Posts: 51011
Joined: June 25, 2012, 9:53 am
Favourite Player: Hodgo
Location: Rockhampton, Central Queensland

Re: Automatic focus on username field when logging in

Post by The Nickman »

Good grief, sort it out, Skeepe
User avatar
zim
Laurie Daley
Posts: 10639
Joined: July 8, 2015, 3:38 pm
Favourite Player: NRL: Joseph Tapine
NRLW: Grace Kemp
Location: Sydney

Re: Automatic focus on username field when logging in

Post by zim »

greeneyed wrote:Maybe Skeepe can help. If you're having trouble staying logged in, however, bookmark this URL and log in via this URL: index.php
Thanks. I'd never even noticed that login form at the bottom of the page.
The Nickman
Mal Meninga
Posts: 51011
Joined: June 25, 2012, 9:53 am
Favourite Player: Hodgo
Location: Rockhampton, Central Queensland

Re: Automatic focus on username field when logging in

Post by The Nickman »

Good grief zim, sort it out
User avatar
reptar
Laurie Daley
Posts: 15753
Joined: January 25, 2005, 9:24 pm
Favourite Player: Josh Hodgson
Location: Brisbane

Re: Automatic focus on username field when logging in

Post by reptar »

I loathe JavaScript. I hope this helps.
Gina Riley: Oh, come on, John. That’s a bit old hat, the corrupt IOC delegate.
John Clarke: Old hat? Gina, in the scientific world when they see that something is happening again and again and again, repeatedly, they don’t call it old hat. They call it a pattern.
Shadow Boxer
Ricky Stuart
Posts: 9174
Joined: May 20, 2008, 2:50 pm

Re: Automatic focus on username field when logging in

Post by Shadow Boxer »

Want a job ?
Image
User avatar
zim
Laurie Daley
Posts: 10639
Joined: July 8, 2015, 3:38 pm
Favourite Player: NRL: Joseph Tapine
NRLW: Grace Kemp
Location: Sydney

Re: Automatic focus on username field when logging in

Post by zim »

Shadow Boxer wrote:Want a job ?
Is that directed at me?
Shadow Boxer
Ricky Stuart
Posts: 9174
Joined: May 20, 2008, 2:50 pm

Re: Automatic focus on username field when logging in

Post by Shadow Boxer »

haha, could be, I have Sitecore CMS, .Net and javascript guys in a team. some of them loathe JS as well,

Public service though mate so its not that simple.
Image
User avatar
zim
Laurie Daley
Posts: 10639
Joined: July 8, 2015, 3:38 pm
Favourite Player: NRL: Joseph Tapine
NRLW: Grace Kemp
Location: Sydney

Re: Automatic focus on username field when logging in

Post by zim »

Shadow Boxer wrote:haha, could be, I have Sitecore CMS, .Net and javascript guys in a team. some of them loathe JS as well,

Public service though mate so its not that simple.
I write JS for a living. I have a fulltime job at the moment though.
If it's like contract work or something that a fulltime worker can do on the side chuck me a PM with the deets.
Shadow Boxer
Ricky Stuart
Posts: 9174
Joined: May 20, 2008, 2:50 pm

Re: Automatic focus on username field when logging in

Post by Shadow Boxer »

Will do mate
Image
The Nickman
Mal Meninga
Posts: 51011
Joined: June 25, 2012, 9:53 am
Favourite Player: Hodgo
Location: Rockhampton, Central Queensland

Re: Automatic focus on username field when logging in

Post by The Nickman »

Hahahaha classic zim
User avatar
greeneyed
Don Furner
Posts: 145091
Joined: January 7, 2005, 4:21 pm

Re: Automatic focus on username field when logging in

Post by greeneyed »

Sim, we might have to make you the new Skeepe! ;)
Image
The Nickman
Mal Meninga
Posts: 51011
Joined: June 25, 2012, 9:53 am
Favourite Player: Hodgo
Location: Rockhampton, Central Queensland

Re: Automatic focus on username field when logging in

Post by The Nickman »

greeneyed wrote:Sim, we might have to make you the new Skeepe! ;)
Jesus, GE, you could at least get his name right when you're offering him Skeepe's job!!
User avatar
greeneyed
Don Furner
Posts: 145091
Joined: January 7, 2005, 4:21 pm

Re: Automatic focus on username field when logging in

Post by greeneyed »

It auto corrected.
Image
Wayne
Sam Backo
Posts: 176
Joined: June 25, 2015, 12:55 pm

Re: Automatic focus on username field when logging in

Post by Wayne »

zim wrote:Please can you update your function that runs when logging in that automatically focusses the username field.
It runs on window load so by then I've already filled out the username and am halfway through my password before it flicks the cursor back to the username field.

This point would be moot if it automatically logged me in each time but it never remembers to.

The function is:

Code: Select all

onload_functions.push('document.getElementById("username").focus();');
It needs to be updated to:

Code: Select all

function someFunction(){
    var elemUsername = document.getElementById("username");
    
    if(elemUsername.value === ''){
        elemUsername.focus();
    }
}


onload_functions.push(someFunction);
Or if you need it in a string on one line:

Code: Select all

onload_functions.push('var elemUsername = document.getElementById("username"); if(elemUsername.value === "")elemUsername.focus();')
You sound like the life of any party.
The Nickman
Mal Meninga
Posts: 51011
Joined: June 25, 2012, 9:53 am
Favourite Player: Hodgo
Location: Rockhampton, Central Queensland

Re: Automatic focus on username field when logging in

Post by The Nickman »

Classic Steinberger
User avatar
zim
Laurie Daley
Posts: 10639
Joined: July 8, 2015, 3:38 pm
Favourite Player: NRL: Joseph Tapine
NRLW: Grace Kemp
Location: Sydney

Re: Automatic focus on username field when logging in

Post by zim »

Jeff Steinberger wrote:You sound like the life of any party.
Someone never left high school.
User avatar
Manchild
Jason Croker
Posts: 4864
Joined: September 28, 2011, 11:29 am
Favourite Player: Past: Brad Clyde
Present: Shaun Fensom
Location: Darwin, NT

Re: Automatic focus on username field when logging in

Post by Manchild »

zim wrote:
Jeff Steinberger wrote:You sound like the life of any party.
Someone never left high school.
Image
Post Reply