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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:45:15+00:00 2026-06-04T03:45:15+00:00

Setup: I have a form and a Submit button. Ideally the user should fill

  • 0

Setup:

I have a form and a “Submit” button. Ideally the user should fill out the form, click “Submit” and then leave the tab. If he tries to leave the tab without saving the changes, I need to alert him with 3 options:

  1. Save
  2. Discard: discard the form data changes, and leave the tab, as if the data was never modified. If user comes back to the same tab, he should see the “unmodified” data.
  3. Cancel: Just dismiss the dialog box, keep the user on the same tab. User can either modify the data further, click save, etc.

Problem:

Implementing Save and Cancel is easy. The issue is with “Discard”. If the user clicks “Discard”, the form data should get restored to what it was before modification.

Is there any way to do this? If I haven’t explained issue properly, please let me know.

  • 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-04T03:45:16+00:00Added an answer on June 4, 2026 at 3:45 am

    You could save the initial state of the form in the jQuery .data() function. Maybe do something like

    $(function(){
        $('form').find(':input').each(function(i, elem) {
             var input = $(elem);
             input.data('initialState', input.val());
        });
    });
    

    Then once you hit discard, you could call a method, say:

    function restore() {
        $('form').find(':input').each(function(i, elem) {
             var input = $(elem);
             input.val(input.data('initialState'));
        });
    }
    

    Note: this is useful if you want to restore the form to what the data was on the page without having the user leave the page. If you don’t want to save the data, just don’t… save the data.

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

Sidebar

Related Questions

I have a form setup but for some reason the JS to submit the
I have setup a form that allows a user to make selections from drop-down
I have a simple form with just one textbox and one submit button. The
We have got a setup where users can either use a web-based form or
I have a project to setup an anonymous feedback form to our website. I
I have a form on the following page: http://mmicet.yazminmedia.com/qseries (Click the Keep me updated
i have a jquery validate setup on the form. whil the form is being
I have a simple spam filter (to prevent spam form submission) setup on a
I have an account registration form where a user can select their account type.
I hoping for a tiny bit of help. I have setup a form which

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.