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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:45:16+00:00 2026-06-17T09:45:16+00:00

I want a confirmation to appear when the user submits a form. The problem

  • 0

I want a confirmation to appear when the user submits a form. The problem is that the confirmation is not appearing and instead it is just navigating the form straight to its destination. Why is the confirmation not appearing? It is not even checking the validation before the confirmation.

Below is html code:

<form id='choiceForm' action='assessment.php' method='post'>
    <select name='currentperson' id='currentperson'>
        <option value=''>Select</option>
        <option value='one'>John Trigger</option>
    </select>

    <p id='submitchoicebtn'><button id='choiceSubmit'>Choose Assessment</button></p>
    <div id='currentAlert'></div>
</form>

Below is jquery:

    function choicevalidation() {
var isDataValid = true;
var currentPerson = document.getElementById("currentperson");
var currentPersonMsg = document.getElementById("currentAlert");
currentPersonMsg.innerHTML = "";

if (currentPerson.value == "") {
    currentPersonMsg.innerHTML = "Please Select a Person";
    isDataValid = false; 
}
else {
    currentPersonMsg.innerHTML = "";
}
    return isDataValid;
}

function showConfirm(){
   console.log(choicevalidation());
   if (choicevalidation()) {
      var confirmMsg = confirm("Are you sure you want to Proceed");
      if (confirmMsg == true) {
        return true;   
      } else {
        return false;
      }
   } else
   {
      return false;
   }
} 

$('#choiceForm').on('submit', showConfirm); 

UPDATE:

Below is my actual code but problem I am receiving is this error:

Jquery code:

    <script type="text/javascript">


       function choicevalidation() {

                var isDataValid = true;

                var currentAssesO = document.getElementById("currentAssessment");

                var currentAssesMsgO = document.getElementById("currentAlert");

          currentAssesMsgO.innerHTML = "";


      if (currentAssesO.value == ""){
          $('#targetdiv').hide();
          currentAssesMsgO.innerHTML = "Please Select an Assessment to edit from the Assessment Drop Down Menu";
          isDataValid = false; 
        }else{
            currentAssesMsgO.innerHTML = "";
        }
            return isDataValid;


        }


             function showConfirm(){

              var examInput = document.getElementById('curentAssessment').value;
              var dateInput = document.getElementById('currentDate').value;
              var timeInput = document.getElementById('currentTime').value;

              if (choicevalidation()) {

             var confirmMsg=confirm("Are you sure you want to take the following Assessment:" + "\n" + "Exam: " + examInput +  "\n" + "Date: " + dateInput + "\n" + "Time: " + timeInput);

             if (confirmMsg==true)
             {
             return true;    
         }else {
        return false;
      }
  } else{
      return false;
   }
} 

   $('#choiceForm').on('submit', showConfirm);    


    </script>

PHP/HTML code:

<?php

// connect to the database


//query which compiles modules drop down menu


$moduleHTML = "";
$moduleHTML .= '<select name="modules" id="modulesDrop">' . PHP_EOL;
$moduleHTML .= '<option value="">Please Select</option>' . PHP_EOL;

while ($sqlstmt->fetch()) {
    $moduleHTML .= sprintf('<option value="%1$s_%2$s_%3$s">%1$s - %2$s</option>' . PHP_EOL, $dbModuleNo, $dbModuleName, $dbModuleId);
}

$moduleHTML .= '</select>';

$pHTML = "";


?> 

<h1>TAKE AN ASSESSMENT</h1>   

<form action="<?php
echo htmlentities($_SERVER['PHP_SELF']);
?>" method="post" onsubmit="return validation(event);"> 
<table> 
<tr> 
<th>Module: <?php
echo $moduleHTML;
?></th> 
</tr> 
</table> 
<p><input id="moduleSubmit" type="submit" value="Submit Module" name="moduleSubmit" /></p> 
<div id="moduleAlert"></div> 
<div id="targetdiv"></div> 
</form> 

<?php

if (isset($_POST['moduleSubmit'])) {
    //query which compiles drop down menu below


    $sessionHTML = '<select name="session" id="sessionsDrop">' . PHP_EOL;
    $sessionHTML .= '<option value="">Please Select</option>' . PHP_EOL;

    while ($sessionqrystmt->fetch()) {
        $sessionHTML .= sprintf("<option value='%s'>%s - %s - %s</option>", $dbSessionId, $dbSessionName, date("d-m-Y", strtotime($dbSessionDate)), date("H:i", strtotime($dbSessionTime))) . PHP_EOL;
    }


    $sessionHTML .= '</select>';


    $assessmentform = "<div id='lt-container'> 
<form action='" . htmlentities($_SERVER['PHP_SELF']) . "' method='post' id='assessmentForm'> 
<p id='warnings'>{$pHTML}</p> 
{$outputmodule} 
<p><strong>Assessments:</strong> {$sessionHTML} </p>   
</form> 
</div>";

    echo $assessmentform;

    $choosesession = " 
<div id='rt-container'> 
<form id='choiceForm' action='assessment.php' method='post'> 

    <p><strong>Chosen Assessment:</strong></p> 
    <table> 
    <tr> 
    <th></th> 
    <td><input type='hidden' id='currentId' name='Idcurrent' readonly='readonly' value='' /> </td> 
    </tr> 
    </table> 
    <p id='submitchoicebtn'><button id='choiceSubmit'>Choose Assessment</button></p> 
    <div id='currentAlert'></div> 
    </form> 

    </div> 
";

    echo $choosesession;

}



?>
  • 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-17T09:45:17+00:00Added an answer on June 17, 2026 at 9:45 am

    You have a syntax error, so the JS is failing and the browser is submiting the form.

    This line is missing the end ‘”‘.

     var confirmMsg=confirm("Are you sure you want to Proceed);
    

    Change it to:

     var confirmMsg=confirm("Are you sure you want to Proceed");
    

    Edit

    Change the event you’re triggering the confirmation on. You’re triggering it on an “onClick”, which is probably happening after the form is already submited, change your last line to:

       $('#choiceForm').on('submit', showConfirm);    
    

    That will trigger the box before the submit is executed. Let me know if that fixes it for you.

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

Sidebar

Related Questions

Before the user closes the form I want to prompt with a confirmation box.
Just want confirmation that this assertion is correct: python cannot ever experience the dangling
My form submits to another page when I do not want it to. The
I want to have a confirmation from the user before they submit a form.
After a user cancels a delete confirmation I want to fire a javascript call
I want to inject a confirmation dialog to allow the user to cancel the
I want to INSERT VALUES after user has clicked OK on the confirmation box.
I have a jdialog and want close it on confirmation after that store the
In my GWT application, I want to ask a user confirmation when he navigates
I just want to get confirmation on Battery Temperature data. I am using GetSystemPowerStatusEx2

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.