-
-
Notifications
You must be signed in to change notification settings - Fork 437
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
Added counter for input fields with maximum-length attribute #2950
Conversation
Nice quality of life feature! My only suggestion is to style it like this, which I think is more standard UI. // display the value, run once at load and on each observed keyup
countdown: function(element) {
var elm = $(element);
var curLen = elm.getValue().length;
var maxLen = elm.retrieve('maxLen');
var count = maxLen - curLen;
var counter = elm.retrieve('counter');
counter.update(' (' + curLen + '/' + maxLen + ')');
if (curLen > maxLen) {
counter.setStyle({'color': 'red'});
} else {
counter.setStyle({'color': 'inherit'});
}
return elm;
} I also changed the conditional to just |
Co-authored-by: Ng Kiat Siong <kiatsiong.ng@gmail.com>
merged and v20ed |
This create a bug: (okay I got this with a custom module...) |
@luigifab if you change that line with |
Changing to @luigifab PR ready if confirmed. |
No, but with |
Description (*)
Adds js-snippet to ...
... to show how many chars are left for valid input.
Note: requires
validate-length
andmaximum-length-XXX
attributeContribution checklist (*)