GithubHelp home page GithubHelp logo

maxlength's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

maxlength's Issues

New line in input causes truncation

When the input has no new lines, the script stops the character from being inserted. Yet when there is a new line in the input, it allows the user to input the character. This causes the end of the input to be trimmed in _checkLength.

I am trying to avoid the end of the input from being trimmed. I want to prevent any further input if the user has reached the maximum character limit.

I noticed that you are replacing new lines with characters in the _checkLength function before checking the length:
var len = value.replace(/\r\n/g, '~~').replace(/\n/g, '~~').length;

But that isn't being done in the keypress event listener in _postAttach:
$(this).val().length.

I think that's why the keypress event listener is allowing the input and then _checkLength is truncating it. But I am a bit confused and I don't want to make a change without being completely certain.

Can I have your input @kbwood? Thanks for the great plugin!

Option to refresh the counter

Hi,

Great work with the lib. It's by far the best I tried.

I have an idea for enhancement. An option for manual refreshing of the counter. When I put some text in the via $(".someinput").val(''); the counter shows the previous length not the actual (correct) one. I must write a character for it to refresh. Calling $(".someinput").maxlength... again doesn't work. It would be great if I could simply refresh it as soon as I change the input's val.

bower file is not a valid json file

The install via bower failed. It seems like the bower.json file is not a valid JSON file (checked with http://jsonlint.com/). The bower.json dependencies part should look like this (Curly brackets instead of Square brackets):

"dependencies": {
"jquery": ">=1.7"
}

Problem with hidden inputs

On hidden inputs the badge is inserted weirdly. It should be at the right but instead it is shown at the left and misplaced.
If I click on the field, it is fixed. Any hints?

image

Update counter when text is changed

Hi,

I am using your lib and when I set the text of a textarea by using val() method of jquery or pasting it by right clicking the mouse, the counter does not update.
Is there a way to force an update of the plugin state for these cases ?

Cannot change options later

It appears it's not possible to change options such as the max length after that method has been called. Is this by design? I'm looking to change the max length based on another input's value. (Total value of the two fields can't exceed a specific number)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.