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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:38:15+00:00 2026-05-25T23:38:15+00:00

Form contains input elements and submit button. Pressing Submit button shows pdf file in

  • 0

Form contains input elements and submit button. Pressing Submit button shows pdf file in new tab in browser.
If enter is pressed to show report, focus moves to submit button. After selection report parameters tag again additional click in input element is required to enter new value to same element.

How to keep focus input element where enter was pressed ?

<form id="Form" class='form-fields' method='post' target='_blank'
action='Render'>

<input id='test' name='test' value='test' /> 
...
  <input id='_submit' type='submit' value='Show report' /> 
</form>

jquery, jqueryui, asp.net mvc2 are used.

update

I have 2 elements with same name in form to allow unchecked checkbox submission:

<input type='hidden' value='false' name='Summary' />
<input type='checkbox' id='Summary' name='Summary' checked />
<select class="ui-widget-content ui-corner-all" id="_Report" name="_Report" size="10">
<option value="LV001">Report1</option>
<option value="LV003">Report2</option>
<option selected="selected" value="LV009">Report3</option>
</select>

I tried code below as suggested in comment. If focus is in checkbox, it focus is not restored. Instead select element is focused. How to fix ?

        $("#Form input:not([type=submit]), textarea, select").focus(function () {
            $('input').removeClass('hasFocus');
            $(this).addClass('hasFocus');
        });
  • 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-05-25T23:38:16+00:00Added an answer on May 25, 2026 at 11:38 pm

    If you want to get back to the last focused item, I think you will need to keep track on the last focused item.

    Something like this will probably achieve what you are looking for:

    $(function() {
        var lastFocus = [];
    
        $('#Form').find(':text,:radio,:checkbox,select,textarea').focus(function() {
            lastFocus = $(this);
        });
    
        $('#Form').submit(function(){    
            if (lastFocus.length == 1)
                lastFocus.focus();
    
            // just to prevent the actual submit - remove this to enable submit
            return false;
        });
    });
    

    I also made a jsfiddle to test: http://jsfiddle.net/Jht6C/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given this form (which contains a submit button): <form id=review_form> <input type=submit id=btn_submit value=Submit
I'm trying to submit a form which contains dynamic elements that were added to
Page contains single form with input elements and jqgrid data. jqGrid data is retrieved
If a HTML form contains multiple input fields: <form> <input id=in1 type=text value=one> <input
I have a table that contains form elements that I need to replace if
I have a form element that contains multiple lines of inputs. Think of each
I have a form that contains a GridView control which is databound to an
I have a form that contains a bunch of checkboxes. Before submitting the form,
I have asp.net form that contains fields. When I access this window, my javascript
I have an asp.net text form that contains numerous decimal fields that are optional.

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.