Skip to:
Content
Pages
Categories
Search
Top
Bottom

Forum Replies Created

Viewing 1 replies (of 1 total)
  • You can definitely limit posts by character count as they’re being inserted. Find where the post form is in your template. I’m using this in Buddypress for the activity stream, so I’m not sure if it’s the same for the regular WP postings. But you should be able to work it around a little bit:

    `

    function limitChars(textarea, limit, infodiv)
    {
    var text = textarea.value;
    var textlength = text.length;
    var info = document.getElementById(infodiv);

    if(textlength > limit)
    {
    info.innerHTML = ‘You cannot write more than ‘+limit+’ characters!’;
    textarea.value = text.substr(0,limit);
    return false;
    }
    else
    {
    info.innerHTML = ‘You have ‘+ (limit – textlength) +’ characters left.’;
    return true;
    }
    }

    Maximum 500 characters.

    `

    You can put that code right before

    `

    Also of note, if you’re doing an AJAX submit that doesn’t refresh the page, you’ll want to have an onclick action set on the submit button that re-inserts the original HTML of the ‘whatsleft’ span back into it. Otherwise they’ll still see the number of characters they had left when they submitted it, even though the form is blank.

    Note: I didn’t write this js, I found it somewhere. Possibly on these forums…but it works :)

Viewing 1 replies (of 1 total)
Skip to toolbar