Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create textarea character countdown #11

Open
basham opened this issue Feb 12, 2015 · 3 comments
Open

Create textarea character countdown #11

basham opened this issue Feb 12, 2015 · 3 comments

Comments

@basham
Copy link
Member

basham commented Feb 12, 2015

Something like:

320 / 500 remaining characters

@basham basham modified the milestone: Minimum Mar 2, 2015
@basham
Copy link
Member Author

basham commented Mar 9, 2015

CKEditor has no build-in character limit, like the maxlength HTML attribute. Would have to use an existing plugin or create something custom.

Have to consider how markup relates to character count. If not included, which is more sensible, then the HTML has to be stripped out in order to ensure a proper plain text count (maximum of 1000 characters, as determined by Success Criteria). Then you're betting that there's no combination of markup that CKEditor would create that would push the character count beyond the database limit (4000 characters).

@basham
Copy link
Member Author

basham commented Mar 9, 2015

http://stackoverflow.com/a/27720326

window.onload = function() {
    CKEDITOR.instances.mytext.on( 'key', function() {
        var str = CKEDITOR.instances.mytext.getData();
        if (str.length > 50) {
            CKEDITOR.instances.mytext.setData(str.substring(0, 50));
        }
    } );
};

@basham basham removed this from the Minimum milestone Mar 9, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant