display alert when form is submitted
<p>I need to display the alert saying thanx your msg is received but this doesnot works so please hel me out how to do.Is there coding error or what i coudnt get to it.i would pe pleased if someone helps me out.thankyou</p>

<pre><code> &lt;h4&gt;Send Your Feedback Here.&lt;p&gt;

      &lt;form name ="register" action="contact.php" method="post"    enctype="multipart/form-data"&gt;

          Name&lt;br&gt;
          &lt;input type="text" name="name" size="30"&gt;
        &lt;/p&gt;
        &lt;p&gt;
        Email&lt;br&gt;
        &lt;input type="text" name="email" size="30"&gt;&lt;/p&gt;&lt;p&gt;
         Message&lt;br&gt;
        &lt;textarea name="message" rows="5" cols="40"&gt;&lt;/textarea&gt;
        &lt;p&gt;

        &lt;/p&gt;          
        &lt;p&gt;
        Security Check&lt;br&gt;

            Sum of &lt;?php $a = rand(0,9);
                        $b = rand(0,9); 
                        echo $a . "+" . $b ; 
                        $result = $a + $b ;
                        ?&gt;  =       
            &lt;input type="text" name="ver"  /&gt;&lt;input type="hidden" name="rval" value="&lt;?php echo $result; ?&gt;" /&gt;
          &lt;button type="button" onClick="validate()"&gt;Send&lt;/button&gt;
        &lt;/p&gt;
      &lt;/form&gt;


&lt;script type="text/javascript"&gt;
        function validate()
    {
        var x = document.register.ver.value;
        var y = document.register.rval.value;
        var nameCheck = document.register.name.value, 
        emailCheck = document.register.email.value, 
        msgCheck = document.register.message.value;

    var msg ="";
    if(x!=y)
    {
    msg+= "Sorry!! Captcha Mismached."+"\n";
    }
    if(nameCheck=="")
    {
        msg+= "Dont you have a name????"+"\n";
    }
    if(emailCheck=="")
    {
        msg+= "Enter email... how am I supposed to contact you"+"\n";
    }
    if(msgCheck="")
    {
        msg+= "Dont you have any messages for me??"+"\n";
    }   

    if(msg!="")
    {
    alert(msg);
    }

    else
    {
            &lt;?php
//Get message data.
$name = $_POST['name'];
$message = $_POST['message'];
$email=$_POST['email'];
$ver = $_POST['ver'];  
$rval = $_POST['rval'];

if($ver==$rval)
{
//Email it.
mail(
  'example@example.com',  //Where to send
"Contact form - $name", //Email subject
  $message,               //Message body
  $email                    //email address  
);
echo "&lt;script type=\"text/javascript\"&gt;alert('Thank you form is submitted');&lt;/script&gt;";
    }
else
{
     echo "&lt;script type=\"text/javascript\"&gt;alert('Wrong captcha');&lt;/script&gt;";
}

?&gt;

    }
}
</code></pre>

<p></p>
