kbwood / maxlength Goto Github PK
View Code? Open in Web Editor NEWjQuery MaxLength Plugin
jQuery MaxLength Plugin
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!
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
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"
}
When we paste the text(ctrl+v) and if text exceeds the max length, replacing the text using val() at line 171.
val() in IE and safari is not triggering change event and its a bug in IE
https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/944049/
solution can we trigger the change event after replacing the text.
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 ?
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)
When you have hit maxlength and mark the text to overwrite it, it doesn't allow it.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.