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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:19:08+00:00 2026-06-17T10:19:08+00:00

My page is submitting straight away without checking for validation or displaying the alert.

  • 0

My page is submitting straight away without checking for validation or displaying the alert. I believe the submit is firing early but is my issue that I have multiple forms?

My question is how can I get the submit to work as it should do where it checks the validation and if that is successful, display the confirmation?

I have had to post my whole code so that you can see the order of the code, because the order of the code maybe my downfall:

    <script type="text/javascript">
    $(document).ready(function () {

        $('#sessionsDrop').change(function () {

            $('#targetdiv').hide();

            if ($(this).val() !== '') {
                var text = $(this).find('option:selected').text();
                var split = text.split(' - ');
                $('#currentId').val($(this).find('option:selected').val());
                $('#currentAssessment').val(split[0]);
                $('#currentDate').val(split[1]);
                $('#currentTime').val(split[2]);
            } else {
                $('#currentAssessment,#currentDate,#currentTime,#currentId').val('');
            }
        });

    });


    function validation(e) {

        var isDataValid = true;

        var moduleTextO = document.getElementById("modulesDrop");

        var errModuleMsgO = document.getElementById("moduleAlert");

        if (moduleTextO.value == "") {
            $('#targetdiv').hide();
            $('#assessmentForm').hide();
            $('#choiceForm').hide();
            $('#submitchoicebtn').hide();
            errModuleMsgO.innerHTML = "Please Select a Module";
            isDataValid = false;
        } else {
            errModuleMsgO.innerHTML = "";
        }

        if (isDataValid === false) {
            if (e.preventDefault) {
                e.preventDefault();
                e.stopPropagation(); //VERY important
            }
            e.returnValue = false;
            e.cancelBubble = true;
        }

        return isDataValid;

    }

    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) {
                submitform();
            }
        }
    }

    $('#choiceForm').on('submit', showConfirm);
</script>
 <h1>TAKE AN ASSESSMENT</h1> //FORM 1
<form action="assessmentchoice.php" method="post" onsubmit="return validation(event);">
    <table>
        <tr>
            <th>Module:
                <select name="modules" id="modulesDrop">
                    <option value="">Please Select</option>
                    <option value="CHI2513_Systems Strategy_1">CHI2513 - Systems Strategy</option>
                    <option value="CHT2220_Interactive Systems_4">CHT2220 - Interactive Systems</option>
                </select>
            </th>
        </tr>
    </table>
    <p>
        <input id="moduleSubmit" type="submit" value="Submit Module" name="moduleSubmit"
        />
    </p>
    <div id="moduleAlert"></div>
    <div id="targetdiv"></div>
</form>//FORM 2
<div id='lt-container'>
    <form action='assessmentchoice.php' method='post' id='assessmentForm'>
        <p id='warnings'></p>
        <p><strong>Selected Module:</strong> CHI2513 - Systems Strategy
            <input type='hidden'
            value='1'>
        </p>
        <p><strong>Assessments:</strong> 
            <select name="session" id="sessionsDrop">
                <option value="">Please Select</option>
                <option value='28'>LDREW - 09-01-2013 - 09:00</option>
                <option value='29'>BQNYF - 10-01-2013 - 10:00</option>
                <option value='22' disabled>WDFRK - 17-01-2013 - 09:00</option>
                <option value='26' disabled>POKUB1 - 25-01-2013 - 15:00</option>
            </select>
        </p>
    </form>
</div>
<div id='rt-container'>//FORM 3 (This is where when submitted it should show confirmation)
    <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>
            <tr>
                <th>Assessment:</th>
                <td>
                    <input type='text' id='currentAssessment' name='Assessmentcurrent' readonly='readonly'
                    value='' />
                </td>
            </tr>
            <tr>
                <th>Date:</th>
                <td>
                    <input type='text' id='currentDate' name='Datecurrent' readonly='readonly'
                    value='' />
                </td>
            </tr>
            <tr>
                <th>Start Time:</th>
                <td>
                    <input type='text' id='currentTime' name='Timecurrent' readonly='readonly'
                    value='' />
                </td>
            </tr>
        </table>
        <div id='currentAlert'></div>
        <p id='submitchoicebtn'>
            <button id='choiceSubmit'>Choose Assessment</button>
        </p>
        </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-06-17T10:19:10+00:00Added an answer on June 17, 2026 at 10:19 am

    here is a DEMO

    try to change following line:

    function showConfirm() { /* your existing code */ }
    

    into

    function showConfirm(e) {
        e.preventDefault();
    
        /* your existing code */
    
        return false;
    }
    

    Have you already tried this:

    function showConfirm(e) {
        e.preventDefault();
    
        var examInput = document.getElementById('curentAssessment').value;
        var dateInput = document.getElementById('currentDate').value;
        var timeInput = document.getElementById('currentTime').value;
    
        if (choicevalidation()) {
    
            return confirm("Are you sure you want to take the following Assessment:" + "\n" + "Exam: " + examInput + "\n" + "Date: " + dateInput + "\n" + "Time: " + timeInput);
        }
        return false;
    }
    
    $('#choiceSubmit').on('click', function(e) {
        if (showConfirm(e)) {
            $('#choiceForm').submit();
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a submit button on the page submitting and it comes back blank
I have a php page for submitting resumes. once they click submit they info
I try to make a language selection page but when submitting the 'value' parameter
How do I stop the form from submitting on page load or refresh? I'm
I want to redirect the user to next page afte successfully submitting their information
I have an updatepanel which after clicking one button is submitting the page. The
Upon submitting this form on my site. It send me to a page that
I have a page that contains several forms, by submitting each one of them,
In short, I'm trying to hit an anchor on the page I am submitting
What I'm trying to do here is, from /expense/new page submitting POST request to

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.