How to validate the textarea field?

hi to all,
I have a form with HTML elements, to take input from user and store it into database table.
Before submitting the data into database, i want to validate the fields.It allows only text data, without any URLs like http:// and any Anchor tags. And also validate the maximum length specified for an text-area. If these are there in text-area it will through s an error specifying the cause.
How to validate these,can any one help me regarding this issue.

Thanking you in advance.

You can use a PHP function called strip_tags

http://php.net/manual/en/function.strip-tags.php

Usage

$textarea = strip_tags($_POST['textarea_name']);

You can also use

$textarea = strip_tags($_POST['textarea_name']);
$textarea = mysqli_real_escape_string($textarea);

or for MySQL not MySQLi

$textarea = strip_tags($_POST['textarea_name']);
$textarea = mysql_real_escape_string($textarea);

which adds a little more security to the variable been passed

If you use prepare statements then you will not need real_escape_string at all.

For validating ANY field you need to consider what it is allowed to contain and either remove anything that is invalid or reject the field if it contains anything invalid.

it is not working.
I add this code but it inserts http:// urls.?
and other way to solve this?

You can also use PHP ‘preg_match’ function to validate your data based on a specific format. See here for more details - http://php.net/manual/en/function.preg-match.php