views:

11

answers:

1

Hi there,

i am searching for a jQuery Plugin which should validate the textarea to the min. character with the count. like the one they are using in this site.

any idea about the existing plugin?

thank you

+1  A: 

You don't need a plugin for that. Here's what you could do if you have jQuery included, at a minimum:

<form action="action.php" method ="post" onsubmit="check(100)">
    <textarea id="txt" name="message"></textarea>
    <input type="submit" name="submit" value="Check!" />
</form>

<script type="text/javascript">
    function check(min) {
        if(strlen($('#txt').val()) < minimum) {
            alert('You need to have more than '+min+' characters to submit!');
            return false;
        }  else {
            return true;
        }
    }
</script>

Let me know if you need more clarifications or if this isn't what you expected.

EDIT

if(strlen($('#txt').val()) < minimum) {

is actually:

if(($('#txt').val()).length < minimum)) {

Got JS mixed up with PHP there :)

Claudiu
thank you for that code. ill try it out .
Ibrahim Azhar Armar
Sorry, small correction in the code, check again now
Claudiu