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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T22:49:34+00:00 2026-05-28T22:49:34+00:00

I want to have a confirmation from the user before they submit a form.

  • 0

I want to have a confirmation from the user before they submit a form. This will prevent accidental POSTing of the form, that may be incomplete or incorrect.

Here is my form element:

<form action="manager.php?method=update&id=<?php echo $user->id;?>" onsubmit="return confirm_update();"  method="POST" id="user_update"> 

This calls my function confirm_update()

function confirm_update()
{
  if(confirm("Do you wish to update details?"))
  {
    return 0;
  }
  else
  {
    return 1;
  }
}

The problem with the script is that it does not prevent the form from POSTing if the user clicks Cancel in the JavaScript prompt.

How do I correct this so that the user does not accidently submit their form?

Here is a full description of the feature I am trying to implement:

Use Case – “Update Details”

  • User goes to update page
  • User enters details in form fields
  • User hits submit button
  • Confirmation message appears
  • If “Ok” button selected proceed to submit form
  • Else cancel action and stay on current page
  • 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-28T22:49:35+00:00Added an answer on May 28, 2026 at 10:49 pm

    Instead of returning 0 and 1, return true and false. You can actually shorten the function to:

    function confirm_update() {
        return confirm("Are you sure you want to submit?");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to have a text box that the user can type in that
I want to have a function that will return the reverse of a list
I have a Web Application and I want to get a confirmation from users
I have a from like this: <% form_for(@user) do |f| %> <%= f.error_messages %>
I have two tables users registered_members I want to confirm values from user table
I have a form that I copied over from new.html.erb and put it in
I want to have a confirmation message box pop up when a user clicks
I have a form for that a user fills out and submits. Once submitted
How do you handle user stories/acceptance tests that have long chains like this one,
I want to create a new user from my form in my new.html.erb file:

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.