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 :)
精彩评论