Sorry for posting again. :| I'm working on this simple evaluation system for our final requirement in this subject. it's working now. my problem is I want to have an error checking (if it's the right term for that). if they leave one textbox blank?

the flow will be, if one textbox leaves blank and when you click submit the output will be "All fields required." then if all fields are filled the output will be "Thank you for your cooperation" then the data entered will be saved to the database.

The action of my submit button is RESULT.PHP
here is the code for it









$con = mysql_connect("localhost","-----","-----");
if (!$con)
  die('Could not connect: ' . mysql_error());

mysql_select_db("----", $con);

$sql="INSERT INTO evaluate (Fname, Date, Subject, TotalA, TotalB, TotalC, TotalD, TotalE, TotalF, TotalG)
VALUES ('$_POST[faculty]','$_POST[date]','$_POST[subject]',$totala,$totalb,$totalc,$totald,$totale,$totalf,$totalg)";

if (!mysql_query($sql,$con))
  die('Error: ' . mysql_error());
echo "Sucessful! Thank you very much for Your kind cooperation";

<br /><br />
<a href="evaluate.html">Back</a>

my problem is. how will i enter the code for error checking? with those multiple fields? Sorry i can't quite figure out how. i have this idea :


if ($e=="" && $f==""){
	echo"All fields required";}
	echo "Thank you for your kind cooperation!";

but then it's for 2 textbox only and i don't use database here. aww.

Member Avatar

use javascript... if all okey, submit !

use javascript... if all okey, submit !

thanks! :) it's okay now. :)

Member Avatar


Miss Indie, how did you do it?! how to check textboxes with empty and reload the page without removing you entered in other field . ..

Anyone can help please need it .. .!

Using jquery:

$(":checkbox").each(function() {
   if($(this).val() === "")
    alert("Empty Fields!!");

using java script:-

var value=getElementById('inputboxid').value ;
alert('input box is empty');