Question: max-length and different markup for overlength text
See original GitHub issueI want to impose a max-length for some of my inputs. But instead of truncating the entered (or pasted) text, I want to apply a different style to that part of the text (at the end of the input field) which causes the overlength. In fact, just like twitter does.
Example (maxlength 3): Too long Adding "Way " to the beginning should result in: Way too long
Is there a mechanism or an easy way to achieve this with draft.js? I already know that I can retrieve the current input length via editorState.getCurrentContent().getPlainText('').length
.
Thanks for any suggestions!
Issue Analytics
- State:
- Created 7 years ago
- Reactions:3
- Comments:5 (1 by maintainers)
Top Results From Across the Web
HTML attribute: maxlength - MDN Web Docs
The maxlength attribute defines the maximum number of characters (as UTF-16 code units) the user can enter into an <input> or <textarea> ....
Read more >Do not count html markup [#1027966] | Drupal.org
The counted length of visible characters doesn't always match 100% with the real length of the text. On a maxlength of 4000 I...
Read more >Difference between "maxlength" & "size" attribute in html?
The maxlength (not max-length ) attribute specifies the maximum length of the input string in characters or, more exactly, in code units.
Read more >eCRAFT Periodic Report Utility (ePRU) Vendor User Guide
Changed required fields to red text throughout, added/modified ... ePRU workbook conform to standard editing, navigation, and other ...
Read more >input type=password – password-input field - HTML5
Specifies that its input element is a one-line plain-text edit control for entering a password. i maxlength = positive integer #: The maximum...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@dtipson checkout this - how to limit draftJS text I haven’t tried it myself yet, but planning to do so
Dynamically adding readOnly also doesn’t seem to help (and in theory wouldn’t be right anyhow, as a maxlength should allow deletion, just not addition). This seems like a pretty basic feature for any text field, so I feel like I’m missing something obvious.