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 8297223
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T15:19:54+00:00 2026-06-08T15:19:54+00:00

On our login page, we have two input fields (username and password), but the

  • 0

On our login page, we have two input fields (username and password), but the second field isn’t made visible until after the first input is submitted and verified. The same button is used to submit twice, once with just the username, and once with both the usename and the password.

I would like to use different submit calls depending on which field(s) are being submitted.

The code currently looks something like this:

if($('input[name=password]').size() > 0)
    $('input[name=password]').focus();
else
    $('input[name=username]').focus();

$('#login-button').click(function() {
    $('form').submit();
});

But, for Google Analytics tracking, I would like to use a different submit call when only the username is being submitted (The 1st submission). The alternate submit would look something like this:

$('#login-button').click(function() {
    $('form').submit(function() {
     _gaq.push('_trackPageview', 'PageName');
});

Can I simply stuff the submits into the if/else somehow? I suspect there’s more to it than that though.

  • 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-08T15:19:56+00:00Added an answer on June 8, 2026 at 3:19 pm

    If you are wanting to check if there is only a username and no password you could check to see if the password field is visible? That is if you want to track before the password field is visible on the screen.

    $('input[name=password]').is(':visible');
    

    so:

    $('#login-button').click(function() {
        $('form').submit(function() {
            if ($('input[name=username]').size() > 0 && !$('input[name=password]').is(':visible')) {
                _gaq.push('_trackPageview', 'PageName');
            }
        });
    });
    

    However if this is not the case and you mean tracking once the password field is visible on the screen you can use the comment above example with adding a (&&) clause in the (if) statement.

    if ($('input[name=username]').size() > 0 && $('input[name=password]').size() < 1) {
        //do some tracking
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In our login page we enter username password and then submit the form. The
I have been using DotNetOpenAuth's OpenIdTextBox control on our login page. We used VS
I have two form elements on my page that act as a smooth login
I have designed login page for one of our website where I have used
I have a web application having three pages, one is login page, second is
I'm trying to get our login portal working, but for some reason it won't
We're seeing an odd pattern in our QA Lab. We have two ASP.NET applications,
We have converted our site from HTTP to HTTPS, and when our login forms
I have a login form on our new website design, and it has a
I have a web app that is being hit by facebook. The login page

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.