1

I have a django contact form and i want the initial text that is found into the form to dissapear when the cursor is in the field.

My form is now:

from django import forms

class ContactForm(forms.Form):
    numele_dumneavoastra = forms.CharField(required=True, label="", initial="Numele Dumneavoastra")
    numarul_de_telefon = forms.CharField(required=True, label="", initial="Numarul de Telefon   ")
    # perioada_cand_va_putem_contacta = forms.CharField(required=True)
    mesajul_dumneavoastra = forms.CharField(required=True, widget=forms.Textarea, label="", initial="Mesajul Dumneavoastra")
    emailul_dumneavoastra = forms.EmailField(required=True, label="", initial="Email")

The text looks like this image enter image description here

When the user inserts his name e.g. "John Doe" i want the initial text " Numele Dumneavoastra" to dissapear from sight. Thank you!

Cohen
  • 944
  • 3
  • 13
  • 40

1 Answers1

1

Not sure I understood, but maybe you should use placeholder and not initial. How do I add a placeholder on a CharField in Django?

eran
  • 6,731
  • 6
  • 35
  • 52
  • Thank you, but they speak about the initial field here. The placeholder is like the initial field from the forms. My code is more pythonic then that link. I simply need, that when you type in the form field to lose the text from the inout box. – Cohen Jan 04 '18 at 21:40