plz tell java script checks for not insert blank value in database when using fckeditor?????

when i not insert any record,the script runs like enter ans but value also inserted in data base..i want not insert blank value and check also runs ....

my code is that:

<script type="text/javascript">

function check2()

   {
      if (document.form1.FCKeditor1.value=="")
       {
        alert("Must Enter answer");
       document.form1.FCKeditor1.focus();
       return false; 
       }
   }
  
</script>

<?php
        include 'config.php';
include 'opendb.php';
	if(isset($_REQUEST['submitt']))
	{
		
		
		$ans=$_POST['FCKeditor1'];
		$sql = "UPDATE class SET answer = '$ans',value='2' WHERE qid='$_REQUEST[qid]' ";
		
		mysql_query($sql);  
		
		
		  
        ?>
		<script>
	alert("reply successfully..");
	location.href="main.php";
</script>
<?php
}

?>

plz tell java script checks for not insert blank value in database when using fckeditor?????

when i not insert any record,the script runs like enter ans but value also inserted in data base..i want not insert blank value and check also runs ....

my code is that:

<script type="text/javascript">

function check2()

   {
      if (document.form1.FCKeditor1.value=="")
       {
        alert("Must Enter answer");
       document.form1.FCKeditor1.focus();
       return false; 
       }
   }

</script>

<?php
        include 'config.php';
include 'opendb.php';
    if(isset($_REQUEST['submitt']))
    {


        $ans=$_POST['FCKeditor1'];
        $sql = "UPDATE class SET answer = '$ans',value='2' WHERE qid='$_REQUEST[qid]' ";

        mysql_query($sql);  



        ?>
        <script>
    alert("reply successfully..");
    location.href="main.php";
</script>
<?php
}

?>

end quote.

Hello waqas,

This is not a place to ask on URGENT basis. please be cool and you will be answered shortly.

Edited 3 Years Ago by mike_2000_17: Fixed formatting

This article has been dead for over six months. Start a new discussion instead.