I'm trying to use the function verifica() in JavaScript to validate data populated in the form, but it doesn't run. What's the problem?
Please, help me in this question.



Code:
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
  $insertSQL = sprintf("INSERT INTO myblog (nome, email, coment) VALUES (%s, %s, %s)",
                       GetSQLValueString($_POST['nome'], "text"),
                       GetSQLValueString($_POST['email'], "text"),
                       GetSQLValueString($_POST['coment'], "text"));

  mysql_select_db($database_conn, $conn);
  $Result1 = mysql_query($insertSQL, $conn) or die(mysql_error());

  $insertGoTo = "Guest.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $insertGoTo));
}

mysql_select_db($database_conn, $conn);
$query_myRdset = "SELECT * FROM myblog ORDER BY id DESC";
$myRdset = mysql_query($query_myRdset, $conn) or die(mysql_error());
$row_myRdset = mysql_fetch_assoc($myRdset);
$totalRows_myRdset = mysql_num_rows($myRdset);
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

body {
<script language="JavaScript">
    function verifica()
    {
        if(document.form1.nome.value==""){
            window.alert("Por favor, forneça seu nome."); form1.nome.focus();
            return;
            }
            if(document.form1.email.value==""){
            window.alert("Por favor, forneça seu e-mail."); form1.email.focus();
            return;
            }
            if (form1.email.value.indexOf('@',0)==-1||form1.email.value.indexOf('.',0)==-1{window.alert("Por favor, forneça corretamente seu e-mail."); form1.email.focus();
            return;
            }
            if(document.form1.coment.value==""){
            window.alert("Por favor, coloque um comentário."); form1.coment.focus();
            return;
            }
            document.form1.action=<?php echo $editFormAction; ?>;
            document.form1.submit();
            }
</script>

        <table width="100%" border="1" align="center" bgcolor="#CC6666">
  <tr>
    <td><form name="form1" action="#" onsubmit="return verifica()"  method="POST">
    <H3> 
    <div align="center"><em>DEIXE AQUI SEU COMENTÁRIO, DÚVIDA OU SUGESTÃO</em>
      </H2>
        <br />
        <br />
      <span class="style6">Nome:        </span></div>
    <span class="style6">
    <label>
      <input name="nome" type="text" id="nome" size="50" />
      </label>
      </span>
      <p class="style6">E-mail:
        <label>
          <input name="email" type="text" id="email" size="50" maxlength="80" />
          </label>
      </p>
      <p class="style6">Comentário
      <br />
        <label>
        <textarea name="coment" cols="80" rows="5" id="coment"></textarea>
        </label>
      </p>
      <p>
        <input name="submit" type="submit" id="submit" value="Enviar"  />
      </p>
      <p>&nbsp;</p>
      <?php do { ?>
        <p class="style6">Em <?php echo $data = implode("/", array_reverse(explode("-", substr($row_myRdset['data'],0,10)))); ?>  &agrave;s <?php echo substr($row_myRdset['data'],11); ?>
        <?php echo $row_myRdset['nome']; ?>
        (mailto:<?php echo $row_myRdset['email']; ?>
        ) escreveu: <?php echo $row_myRdset['coment']; ?>  </p>
        <?php } while ($row_myRdset = mysql_fetch_assoc($myRdset)); ?><input type="hidden" name="MM_insert" value="form1">
</form></td>
  </tr>
</table>

    </div>
  </div>
</div><div style="clear:both;"></div>
</body>
</html>
<?php
mysql_free_result($myRdset);

mysql_free_result($myRdset);
?>