Counting problem with character counter for a textarea form field #755
-
Hello together, we added character counters to the textarea form fields on our edit and addTrip pages. Actually we have the problem on our edit page that we have already text in our textarea and the counter doesn´t work on initially loading the page. We know that the onChange method only works if some changes happen in the textarea but we have no idea how we can subtract the already existing characters on the edit page from the counter on initially loading the page. Components/TripForm/index.js: import { import ConfirmationMessage from "../ConfirmationMessage"; export default function TripForm() { async function handleSubmit(event) {
} function handleCountLetters(event) { return (
); Maybe you have an idea. Thank you in advance. PS: I am sorry, actually i can´t create a pull request because a pull request about an another user story is still in progress. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
We found the answer, we used the trips.description.length as the initial state and subtracted it from 150.
|
Beta Was this translation helpful? Give feedback.
We found the answer, we used the trips.description.length as the initial state and subtracted it from 150.