Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8722521
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:26:22+00:00 2026-06-13T07:26:22+00:00

I have an issue with gaining focus on my first input field in my

  • 0

I have an issue with gaining focus on my first input field in my login dropdown.
I’m using jquery 1.7.2 and bootstrap 2.1.1 with only the modal and dropdown functions.
They both work great, I call dropdowns and modals through data target and not JS.

I’ve been trying for hours and searching for answers everywhere but I can’t find a way to get my first input field (#j_username) to gain focus when the dropdown is shown.

The shown event from bootstrap does not fire, so I did a jQuery on() event which fires fine.
My selector works fine, I’ve tested it in the console with other methods (hide() and show(), and various ways of selecting the same field (either its id #j_username) or ($(“#fields input:first”).

The event fires correctly but no way to get the input field to gain focus.
I’ve tried HTML5’s autofocus property but it doesn’t seem to work either.

Any ideas? Thanks in advance

The handler is part of function onPageReady().

$("#loginlnk").on('click', function(){
console.log("FIRE");
$("#j_username").focus();
});

<span class="span-dropdown">
    <button class="dropdown-toggle btn grey" role="button" id="loginlnk" data-toggle="dropdown" href='#'>Login</button>
    <div class="dropdown-menu auth" role="menu" id="signin" aria-labelledby="loginlnk">
    <form-login action="/j_spring_security_check" method="POST" always-use-default-target='false'  default-target-url="/home.do" authentication-failure-url="/welcome.do" />
    <div class="dropdown-caret right">
        <span class="caret-outer"></span>
        <span class="caret-inner"></span>
    </div>
    <div id="fields">   
         <div id="username">Enter your email address
         <input class="inputs login" autofocus="autofocus" id="j_username" name="j_username">
          </div>
          <div id="password">Password
          <input class="inputs login" id ="j_password" name="j_password" type="password" >
          </div>
     </div>
     <div id="submit">
        <button class="btn mapit" id="signinbtn" type="submit" value="Login" onClick="login(1)" tabindex="102">Login</button>
    </div>
    <div id="links">
        <a id="pwdlnk" href="javascript:lostPwd();">Lost your password?</a>         
    </div> 
    <div id="lostpwd">
        Enter your email to receive recovery instructions.
        <div class="container">
        <input class="inputs login" type="email" id="lost_username" tabindex="400">
        <button class="btn" id="lostpwdbtn" type="submit" value="" onClick="forgotPassword()" tabindex="401">Recover</button>
        </div>
    </div>                  
 </form-login>

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T07:26:23+00:00Added an answer on June 13, 2026 at 7:26 am

    The form has not yet rendered as the click event is fired. And there are no plans to add such events to Bootstrap dropdowns.

    A quick way around this is:

    $("#loginlnk").on('click', function(){
        console.log("FIRE");
        var x = setTimeout('$("#j_username").focus()', 700);
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have issue with sending AJAX body request using jQuery CORS with custom Content-type.
i have done drag and drop using with jquery. here i have issue that
Have an issue with jquery autocomplete, focus function After i type something in the
We are new to ROR, We have issue in creating Login/Logout process in ROR
I have an issue with jquery and history.back(): I got a link: <a href=#
I have issue wuth Firefox not displaying style text-decoration: line-through. I am using jqGrid
i have issue regarding Paging using filterexpression. here's the piece of code for filtering
MSSQL database. I have issue to create database using old databases data. Old database
Im having an issue with using prototypes observe function and gaining access to this
have an issue updating magento product from frontend using a module that its function

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.