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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.