Wednesday, 21 August 2013

Django Forms: En-/Disable a Charfield dynamically

Django Forms: En-/Disable a Charfield dynamically

i have a form with a ChoiceField and a CharField. Now i want to enable the
CharField just when i select a specific choice of the ChoiceField (e.g.
choice 3). Otherwise the CharField should be disabled.
My ChoiceField
choices = (('1', 'some text',),
('2', 'some text',),
('3', 'some text',))
host = forms.ChoiceField(choices = choices)
And a simple CharField
hostAdress = forms.CharField()
Do you have any ideas to get it this way?

No comments:

Post a Comment