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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:16:12+00:00 2026-05-27T01:16:12+00:00

I have a slight problem with my confirmation. What happened before I included a

  • 0

I have a slight problem with my confirmation.

What happened before I included a confirmation box in my code was that when I click a button (name=preQuestion), if there are any validation errors then it will show validation errors on the page and not submit the form, if there are no validation errors then it will submit the form.

But what I want to do now which I can’t get working and which keeps giving me errors is that if there are validation errors then it will do what it is doing at the moment but if there are no validation errors, then I want a confirmation box to appear stating … and user will click ok or cancel. If user clicks ok then submit form, if user clicks cancel then close confirmation box and stay on same page. Where am I going wrong?

Below is javascript code (I have shorten code so it doesn’t include all validation code or it would be a code overflow):

function validation() {

                var isDataValid = true;

                var sessionNoO = document.getElementById("sessionNo");               
                var questionNumberO = document.getElementById("txtQuestion");
                var roomTextO = document.getElementById("room");

                var errSessionMsgO = document.getElementById("sessionNoAlert");
                var errQuesMsgO = document.getElementById("numberAlert");
                var errRoomMsgO = document.getElementById("roomAlert");

                var trimmedRoomText = roomTextO.value.replace(/^\s+/, '').replace(/\s+$/, '');



   if (sessionNoO.value == ""){
          errSessionMsgO.innerHTML = "Please Enter in the Number of Sessions you Require";
          isDataValid = false;   
    }else if (sessionNoO.value == 0){
        errSessionMsgO.innerHTML = "Number of Sessions Must be More than 0";
          isDataValid = false;
      }else{
                errSessionMsgO.innerHTML = ""; 
            }


    if(questionNumberO.value == 0){
        errQuesMsgO.innerHTML = "Please Set the Number of Questions";
        isDataValid = false;
    } else {
        errQuesMsgO.innerHTML = "";
    } 

          if (roomTextO.value == ""){
          errRoomMsgO.innerHTML = "Please Enter in a Room Number";
          isDataValid = false;
            }else if (!trimmedRoomText.length){
          errRoomMsgO.innerHTML = "Please Enter in a Room Number"; 
          isDataValid = false;      
        }else{
                errRoomMsgO.innerHTML = ""; 
            }

            return isDataValid;

            }

            function submitform()
            {

        var sessionFormO = document.getElementById("sessionForm");

        sessionFormO.submit();

            }

            document.getElementsByName("prequestion")[0].addEventListener('click', myClickHandler);

                function myClickHandler(){
     if(validation()){

         function showConfirm(){

         var confirmMsg=confirm("Make sure that your details are correct, once you proceed after this stage you would 
         not be able to go back and change any details towards your Session.Are you sure you want to Proceed?");

         if (confirmMsg==true)
         {
         submitform();   
         }else{
         parent.close();    
         }

     }
}
} 

Html form code (not showing whole form so that there is no code overflow):

<form action="QandATable.php" method="post" id="sessionForm">
          <p><strong>2: Number of Sessions you Require:</strong> <input type="text" id="sessionNo" onkeypress="return isNumberKey(event)"><br/><span id="sessionNoAlert"></span></p>
            <p><strong>8: Room:</strong> <input type="text" id="room"><br/><span id="roomAlert"></span></p>      <!-- Enter Room here-->
            <table>
            <tr>
            <th>9: Number of Questions:</th>
                <td class="spinner"><input type="text" class="spinnerQuestion" id="txtQuestion" name="textQuestion"></td>
                <td><button class="scrollBtn" id="btnQuestionUp" type="button"><img src="Images/black_uppointing_triangle.png" alt="Increase" /></button>
                <button class="scrollBtn" id="btnQuestionDown" type="button"><img src="Images/black_downpointing_triangle.png" alt="Decrease" /></button></td>
                </tr>
                </table>
                <div id="numberAlert"></div>
                <p><strong>10: </strong><input class="questionBtn" type="button" value="Prepare Questions" name="prequestion" onClick="myClickHandler()"/></p>      <!-- Prepare Questions here-->

        </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-27T01:16:12+00:00Added an answer on May 27, 2026 at 1:16 am

    I have made correction in your code and now its working fine check it out
    function validation() {

                    var isDataValid = true;
    
                    var sessionNoO = document.getElementById("sessionNo");               
                    var questionNumberO = document.getElementById("txtQuestion");
                    var roomTextO = document.getElementById("room");
    
                    var errSessionMsgO = document.getElementById("sessionNoAlert");
                    var errQuesMsgO = document.getElementById("numberAlert");
                    var errRoomMsgO = document.getElementById("roomAlert");
    
                    var trimmedRoomText = roomTextO.value.replace(/^\s+/, '').replace(/\s+$/, '');
    
    
    
       if (sessionNoO.value == ""){
              errSessionMsgO.innerHTML = "Please Enter in the Number of Sessions you Require";
              isDataValid = false;   
        }else if (sessionNoO.value == 0){
            errSessionMsgO.innerHTML = "Number of Sessions Must be More than 0";
              isDataValid = false;
          }else{
                    errSessionMsgO.innerHTML = ""; 
                }
    
    
        if(questionNumberO.value == 0){
            errQuesMsgO.innerHTML = "Please Set the Number of Questions";
            isDataValid = false;
        } else {
            errQuesMsgO.innerHTML = "";
        } 
    
              if (roomTextO.value == ""){
              errRoomMsgO.innerHTML = "Please Enter in a Room Number";
              isDataValid = false;
                }else if (!trimmedRoomText.length){
              errRoomMsgO.innerHTML = "Please Enter in a Room Number"; 
              isDataValid = false;      
            }else{
                    errRoomMsgO.innerHTML = ""; 
                }
    
                return isDataValid;
    
                }
    
                function submitform()
                {
    
            var sessionFormO = document.getElementById("sessionForm");
    
            sessionFormO.submit();
    
                }
    
                document.getElementsByName("prequestion")[0].addEventListener('click', myClickHandler);
    
        // problem was here             
    function myClickHandler()
    {
         if(validation())
    {
    showConfirm();
    
    
         }
    }
    
    
     function showConfirm(){
    
             var confirmMsg=confirm("Make sure that your details are correct, once you proceed after this stage you would not be able to go back and change any details towards your Session.Are you sure you want to Proceed? ");
    
             if (confirmMsg==true)
             {
             submitform();   
             }else{
             parent.close();    
             }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a slight problem with creating a button on the server side code.
am new here. i have a slight problem; PLease look at the following code
I've wrote this simple piece of code. And I have a slight problem with
I have this GWT code below which have some slight problem: It's either the
I have a slight problem implementing vibration functionality in my application. My code is:
I have a slight problem with this code: string[] sWords = {Word 1, Word2}
I have a slight problem with Powershell strings. There is a Java program I'm
Hey all, have a slight problem here. In CakePHP I have a controller that
I have a slight problem my code works fine but it re-sizes my entire
Slight problem i have been pondering on, i have a class that loads a

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.