Q:

validate the textarea in php

I m trying an unsubscribe form in php.I am facing the problem while displaying error messages in php. When a 3rd option radio button is clicked texatarea displays and when the textarea is blank when the 3rd option is clicked I want the error message to be displayed as text and to be displayed together with other error messages in php.
How can i validate the textarea?
Here is the code.
   <script type="text/javascript">
        $(function() {
    $(document).ready(function() {
$("#otherAnswer").hide();
        $(".opt").change(function(){
            var id=$(this).attr("id");
            if(id=="mail2")
            {
                $("#otherAnswer").show();
            }
            else
            {
                $("#otherAnswer").hide();
            }
            });

                });

    </script> 
    <?php
     if (isset($_POST['submit'])) {
        $error = "";

    if (!empty($_POST['email'])) {
        $email = $_POST['email'];
        } else {
        $error .= "Email ID. <br />";
        }
    if (!empty($_POST['mail'])) {
      $mail = $_POST["mail"];
        $otherAnswer=$_POST["otherAnswer"];
    }
    else {
        $error .= "Other reason <br />";
        }

    <div id="contactForm">

           <?php
          if (!empty($error)) {
          echo '<p class="error"><strong>Your request has NOT been sent.<br/> Please correct / re-enter the following and try again</strong><br/>' . $error . '</p>';
          } elseif (!empty($success)) {
          echo $success;
          }
        ?>

                    <form action="" method="post"  style="margin-top:20px;" id="feedbackform">
                      <input type="hidden" name="subject" value="Form Submission" />
                      <input type="hidden" name="redirect" value="" />
    <label>Email ID:</label>
                      <input type="text" name="email" value="" style="margin-left:30px;"<?php if (isset($_POST['email'])) { echo $_POST['email']; } ?>" />
                        <br/><br/>

                <label >
        <input name="mail" type="radio" id="mail" value="I receive too many e-mails" class="opt"/>I receive too many e-mails<br /></label>
    <label ><input name="mail" id="mail1" type="radio" value="I donâ€™t find the e-mails interesting or useful"class="opt" />I donâ€™t find the e-mails interesting or useful</label>
    <br/>
      <label >
    <input name="mail" type="radio" id="mail2" value="other" class="opt"/>Other, please give details:</label><br/><br/>
   <textarea class="textbox" style="display:none;width: 485px; margin-left:10px; height:110px;" type="text" name="otherAnswer" id="otherAnswer"/></textarea><br/>
     <span style=" width:700px; text-align:center;">      
    <input type="submit" class="submit" name="submit" value="Unsubscribe" /> 

A:

Add this validation check in your php code
if($_POST["mail"]=='other' && empty($_POST["otherAnswer"])){
    $error .= "Other, please give details. <br />";
}

