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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T00:29:33+00:00 2026-05-31T00:29:33+00:00

I am trying to prevent the page jumping to top when the user submits

  • 0

I am trying to prevent the page jumping to top when the user submits the form. There are many people suggesting return false. However, it also prevents the form to be submitted too.

I was wondering if anyone could help me about it.

**JQuery**

$('#submit').click(function(){ //doesn't work
    return false;
})

$('form').submit(function(){  //doesn't work either
    return false;       
})



**Html**
<form...>
<input>...
<input>...
<input>...

<input type='submit' id='submit' value='submit'>

</form>
  • 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-31T00:29:34+00:00Added an answer on May 31, 2026 at 12:29 am

    When you submit the form you are effectively loading a new page. Returning false in the submit handler simply tells the browser not to bubble the event and not perform the default event, which in this case is submiting the form, which is why nothing is happening when you do this.

    There are several solutions to your problem. If you are redirecting your user (after the form submission) back to the form page but with errors, you can include the “fragment identifier” in the url. Have the fragment identifier point to the ID of you form and the browser will automatically go to that part of the document. Example:

    <form id="my-form">
        ...
    </form>
    

    And your url would be:

    host/path?query=querystring#my-form
    

    If you want to avoid having the page reload, try doing your validation in JS. The jQuery validation plugin is very easy to use and simply fantastic. See here to find out how to use it. It’s great because it does most of the heavy lifting for you and has a set of common, default validation methods.

    Alternatively you can submit your form via ajax and return any validation errors that the server picks up. If you don’t have any errors then you can redirect to the next page. If there are errors then stick them in the form or display an alert. This solution will avoid you having to replicate any complex validation logic on the client (if you want to use the jQuery validate plugin).

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

Sidebar

Related Questions

I have a page with a form where I'm trying to prevent duplicate submission,
I'm trying to prevent output cached page from being ejected from my asp.net output
I'm trying to prevent information to be copied from a page (for non-technical users
I can't get this to work. I am trying to prevent a user to
I have the following code. I am trying to prevent my page from resubmitting
I am trying to create a force-download page to prevent browsers from opening files
I'm trying to prevent a page change in jquery mobile depending on what page
So I'm simply trying to prevent a flash video from playing on page load
Im trying to clear the browser cache when the page is loaded and/or prevent
I'm trying to prevent a javascript file from loading if a user is on

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.