Within my models, I have a forms.Form that includes a textarea field:
answer1 = forms.CharField(label='Answer 1', widget=forms.Textarea(attrs={"placeholder":"Type your answer...", "rows":6, "cols":45}), max_length=150)
When it comes to views:
...
form = SurveyForm(request.POST)
...
...render(...{'form':form})
As for my template:
<p><label>Answer 1:</label> {{ form.answer1 }}</p>
Now, I am interested in implementing JavaScript to display a character counter for the textarea. I need to include some additional information in the textarea, such as:
onKeyDown="MyCountFunction('textbox','char',150)"
Should I include all this information about the textarea within my forms.Form, similar to how I added the placeholder, or is there a more efficient way to do this in my templates? What is the best approach for achieving this?