title: PHP - javascript Validation - radio Buttons Alert
body: <p>i have three radio buttons input within a form. i want alert box appears when user click submit when one of the fields is null. how can i do that using javascript ?</p>
  
  <p>my code so far is ..</p>
  
  <pre><code>  &lt;?php
  
     session_start();
     $Load=$_SESSION['login_user'];
     include('../connect.php');
  
  
                  if (isset($_POST['submit']))
  
  {  
  
     $v1 = intval($_POST['v1']);
     $v2 = intval($_POST['v2']);
     $v3 = intval($_POST['v3']);
     $total = $v1 + $v2 + $v3  ;
  
   mysql_query("INSERT into Form1 (P1,P2,P3,TOTAL)
   values('$v1','$v2','$v3','$total')") or die(mysql_error());
   header("Location: mark.php");
   }
  
  
  ?&gt;
  
  
  &lt;html&gt;
  
  &lt;head&gt;
  
  &lt;?php
  
  
  if(!isset($_SESSION['login_user']))
  
  header("Location:index.html");
  
  
  
  ?&gt;
    &lt;title&gt;Q&amp;A Form&lt;/title&gt;
  
  &lt;/head&gt;
  
  &lt;body&gt;
  
  
      &lt;center&gt;&lt;form method="post" action="mark.php"  &gt;
  
      &lt;table style="width: 20%" &gt;
          &lt;tr&gt;
      &lt;th&gt; Criteria &lt;/th&gt;
      &lt;th&gt; &lt;/th&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
      &lt;th&gt; Excellent &lt;/th&gt;
      &lt;td &gt;  4 &lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
      &lt;th &gt; Good &lt;font size="3" &gt; &lt;/font&gt;&lt;/th&gt;
      &lt;td&gt;  3 &lt;font size="4" &gt; &lt;/font&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
      &lt;th &gt; Average &lt;font size="3" &gt; &lt;/font&gt;&lt;/th&gt;
      &lt;td &gt;  2 &lt;font size="4" &gt; &lt;/font&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
      &lt;th &gt; Poor &lt;font size="3" &gt; &lt;/font&gt;&lt;/th&gt;
      &lt;td &gt;  1 &lt;font size="4" &gt; &lt;/td&gt;
      &lt;/tr&gt;
  
  
  
  
  &lt;font size='4'&gt;
      &lt;table style="width: 70%"&gt;
          &lt;tr&gt;
  &lt;th &gt; School Evaluation &lt;font size="4" &gt; &lt;/font&gt;&lt;/th&gt;
  
  &lt;tr&gt;
  &lt;th &gt; Criteria &lt;font size="4" &gt; &lt;/font&gt;&lt;/th&gt;
              &lt;th&gt; 4&lt;font size="4" &gt; &lt;/font&gt;&lt;/th&gt;
              &lt;th&gt; 3&lt;font size="4" &gt; &lt;/font&gt;&lt;/th&gt;
              &lt;th&gt; 2&lt;font size="4" &gt; &lt;/font&gt;&lt;/th&gt;
              &lt;th&gt; 1&lt;font size="4" &gt; &lt;/font&gt;&lt;/th&gt;
  
          &lt;/tr&gt;
  &lt;tr&gt;
  &lt;th&gt; Your attendance&lt;font size="4" &gt; &lt;/font&gt;&lt;/th&gt;
  &lt;td&gt;  &lt;input type="radio" name ="v1" value = "4"    onclick="updateTotal();"/&gt;&lt;/td&gt;
  &lt;td&gt;  &lt;input type="radio" name ="v1" value = "3"    onclick="updateTotal();" /&gt;&lt;/td&gt;
  &lt;td&gt;  &lt;input type="radio" name ="v1" value = "2"    onclick="updateTotal();" /&gt;&lt;/td&gt;
  &lt;td&gt;  &lt;input type="radio" name ="v1" value = "1"    onclick="updateTotal();" /&gt;&lt;/td&gt;    
  &lt;/tr&gt;
  
  &lt;tr&gt;
  &lt;th &gt; Your grades  &lt;font size="4" &gt; &lt;/font&gt;&lt;/th&gt;
  &lt;td&gt;  &lt;input type="radio" name ="v2" value = "4"    onclick="updateTotal();" /&gt;&lt;/td&gt;
  &lt;td&gt;  &lt;input type="radio" name ="v2" value = "3"    onclick="updateTotal();" /&gt;&lt;/td&gt;
  &lt;td&gt;  &lt;input type="radio" name ="v2" value = "2"    onclick="updateTotal();" /&gt;&lt;/td&gt;
  &lt;td&gt;  &lt;input type="radio" name ="v2" value = "1"    onclick="updateTotal();" /&gt;&lt;/td&gt;    
  &lt;/tr&gt;
  
  &lt;tr&gt;
  &lt;th &gt;Your self-control &lt;font size="4" &gt; &lt;/font&gt;&lt;/th&gt;
  &lt;td&gt;  &lt;input type="radio" name ="v3" value = "4"    onclick="updateTotal();" /&gt;&lt;/td&gt;
  &lt;td&gt;  &lt;input type="radio" name ="v3" value = "3"    onclick="updateTotal();" /&gt;&lt;/td&gt;
  &lt;td&gt;  &lt;input type="radio" name ="v3" value = "2"    onclick="updateTotal();" /&gt;&lt;/td&gt;
  &lt;td&gt;  &lt;input type="radio" name ="v3" value = "1"    onclick="updateTotal();" /&gt;&lt;/td&gt;    
  &lt;/tr&gt;       
  
  
          &lt;/tr&gt;
      &lt;/table&gt;
  
  
      &lt;br&gt;
      &lt;td&gt;&lt;input type="submit" name="submit" value="Submit"&gt;
  
      &lt;input type="reset" name="clear" value="clear" style="width: 70px"&gt;&lt;/td&gt;
  
  
   &lt;/form&gt; 
  &lt;/center&gt;
  </code></pre>
  
  <p>i have the idea to put like </p>
  
  <pre><code>&lt;form name="form1" action="mark.php" onsubmit="return validateForm()" method="post"&gt; 
  </code></pre>
  
  <p>but what should i write in the validateForm() ?</p>