如何在单击提交之前验证textarea? [重复]

This question already has an answer here:

I am developing website that allow user sending feedback to system. I have created feedback form by using textarea and button for submit. The most important thing is when user click on submit, if user didn't input some words that I want them to input, that feedback won't send to the system; it will alert user to input that word.

Since now, i just create a simple code that will echo some warning if user didn't input the word that i want them to input in feedback form after click submit.

Here is my code

<form action="main.php" method="post">
    <textarea cols='10' rows='5' name='text'></textarea>
    <br/>
    <input type='submit' name='add' Value='Add to list' />
</form>

<?php
   if (isset($_POST['add'])) {
       $imp_word = array('dear', 'thank', 'hello'); // Add more
       $entry = $_POST['text'];
       /*
           i don't know how to write
       */
  }
?>

Can any one help me to solve this problem?

</div>

Try with substr like

if (isset($_POST['add'])) {
    $imp_word = array('dear', 'thank', 'hello'); // Add more
    $entry = $_POST['text'];
    foreach($imp_word as $wrd) {
        if(substr($entry,$wrd)) { 
            echo 'You have '.$wrd.' In your text<br>';
        }
    }
}

Same mentined HERE

if(isset($_POST['add'])) {
   $text = $_POST['text'];
   if(empty($text)) {
      echo "Please enter feed back";
   } else {
      echo "do ever what you want...";
   }
}