开发者

Min. Character Count Plugin for textarea like the one in this site?

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

any idea about the existing plugin?

thank you


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 :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜