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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:42:24+00:00 2026-06-13T13:42:24+00:00

I have done some javascript validation for my HTML form but I need to

  • 0

I have done some javascript validation for my HTML form but I need to include some PHP validation as well, so I included the PHP validation for all the features in the HTML form when the user forget to enter something in a text input or select a radio button.

Problem is that if the user clicks on the “Prepare Question” submit button, then it doesn’t display the echos when it hould do, instead it submits the form, I don’t want this to happen. I don’t want the form to be submitted until the php validation is met successfully. What do I need to change in my code in order for this to work:

Below is the code:

<form action="QandATable.php" method="post" id="sessionForm">
<p><strong>1: Your Assessment ID: </strong><span id="idFont"><?php echo $id; ?></span></p>
<input type='hidden' name='id' value='<?php echo $id; ?>' />
<p><strong>2: Number of Assessments you Require:</strong> <input type="text" id="sessionNo" name="sessionNum" onkeypress="return isNumberKey(event)" maxlength="5" /></p>
<p><strong>3: Duration:</strong> <input type="text" id="durationpicker" name="durationChosen" readonly="readonly" /></p>
<p><strong>4: Date:</strong> <input type="text" id="datepicker" name="dateChosen" readonly="readonly" /></p>
<p><strong>5: Start Time:</strong> <input type="text" id="timepicker" name="timeChosen" readonly="readonly" /><span class="timepicker_button_trigger"><img src="Images/clock.gif" alt="Choose Time" /></span></p>
<p><strong>6: </strong><input class="questionBtn" type="submit" value="Prepare Questions" name="prequestion" onClick="myClickHandler(); return false;"/></p>      <!-- Prepare Questions here-->

</form>

<?php

if (isset($_POST['prequestion'])) {

if(empty($_POST['sessionNum'])) {
   echo "Please Set the Number of Assessments";
} 
elseif(empty($_POST['durationChosen'])) {
  echo "Please Select your Assessment's Duration";
}
elseif(empty($_POST['dateChosen'])) {
  echo "Please Select a Date";
}
elseif(empty($_POST['timeChosen'])) {
  echo "Please Select a Start Time";
}
else {

?>

         <script type="text/javascript">

function myClickHandler(){ 
     if(validation()){ 
                showConfirm(); 
     } 
}

<?php

}

}
?>
  • 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-13T13:42:25+00:00Added an answer on June 13, 2026 at 1:42 pm

    PHP is a server-side scripting language so there is no straight forward way you can do a PHP validation on a form before it is submitted.

    What you can do, if you have to do PHP validation for one reason or another, is to submit the field values asynchronously (in a non visible way). You could f ex use javascript to call a GET on a hidden iframe with the form data and return errors from a separate php page (f ex calling /hidden/formcheck.php?sessionNum=XX&(…) and return false or true).

    If you really want to do it in that way you’d be much better off using jQuery or some similar library who has a tonne of ready made features for remote URL calling (like jQuery’s http://api.jquery.com/load/ )

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

Sidebar

Related Questions

I have done some stuff in jQuery and Javascript before, but unfortunately I am
I have done some project in Irrlicht and it compiles all well, however when
i have done some code in jquery but where i commented in this bellow
I have done some searching, but I couldn't find a definitive list of whitespace
I have done some web based projects, but I don't think too much about
According to http://www.codingforums.com/archive/index.php/t-98569.html , the date validation could be done using the javascript's date
I want to simulate ECG using javascript. i have done some part using JSXGraph
I am currently creating a website and have some javascript that works in all
I have done some research about Javascript sorting algorithms performance comparison, and found unexpected
ok i have a form on which i have some validation through dataannotation which

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.