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

  • Home
  • SEARCH
  • 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 6709657
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:54:28+00:00 2026-05-26T07:54:28+00:00

I want to warn a user when he is about to discard changes in

  • 0

I want to warn a user when he is about to discard changes in a form when switching to another page.

Is if (!confirm("Are you sure")) return false;... kind of message considered good practice?
Should I use a modalpanel for that? (More work)

Thanks!

  • 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-26T07:54:29+00:00Added an answer on May 26, 2026 at 7:54 am

    There are two pieces to this question:

    1. If using confirm() is considered good practice.
    2. If this will work to prevent users from leaving the page.

    The two principles on which to judge the first part are: (1) never throw away user input and (2) don’t halt a user’s flow. confirm() dialogs are modal, which means they stop users in their tracks. They are forced to answer the question without moving on. Generally, this is bad. If you can do it in a way that doesn’t stop the user’s flow, that is better. (For example, storing the input in a cookie or on the server or emailing a link to the user to finish the form later.) If you can’t find another way, a modal dialog might be better than losing the data entered.

    For the second part it depends on your implementation whether this will work or not. I have a feeling it won’t because the user can always type something into the address bar to get away from your page. The surest way to prompt a user before leaving the page no matter the escape vector is to use the window object’s onbeforeunload event and return a string. Implementation details at the Mozilla Developer Network.

    window.onbeforeunload

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

Sidebar

Related Questions

I'm using a page unload trigger to warn the user of unsaved changes while
I have a DataGridTemplateColumn with DataTemplate as a PasswordBox. I want to warn user
If the user refreshes the page in question it will add another record to
I want to add a warning message during the compilation to warn the user
I want to prompt the user to enter a database name and warn him
I want to warn users of Internet Explorer 6 using my site, that IE6
Want to know what the stackoverflow community feels about the various free and non-free
I want my error page of my seam application to redirect to the home
I want to find every application listed in the user program menu. I use
I'm creating an ASP.NET website and I want to implement logic to warn the

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.