Note that there are some explanatory texts on larger screens.

plurals
  1. POdjango turn validation on and off via a drop down list
    primarykey
    data
    text
    <p>I am a newbie to django, and this issue has me stumped. I cannot see the error, looked for many hours now!</p> <p>I am trying to turn off or turn on the validation of two text fields based on the value of a drop down list. If the user selects index values 8888 or 9999 the validation is turned off - this appear to be working (woo hoo!!).</p> <p>When the user selects another value (not 8888 or 9999) the validation is turned on, but remains on even when I have filled the relevant text fields. The form will not submit even when the text fields are filled because the validation is still triggered.</p> <p>Here is the code in my forms.py page:</p> <pre><code> def clean(self): cd_wrtdf = super(WorkplaceRelatedTrainingDetailsForm, self).clean() if cd_wrtdf['workplace_training_display_type'] == 8888 or cd_wrtdf['workplace_training_display_type'] == 9999: self.cleaned_data['workplace_training_institute'] = '' self.cleaned_data['workplace_training_date_completed'] = '' self.cleaned_data['workplace_training_date_expiry'] = '' else: if cd_wrtdf['workplace_training_display_type'] == 0: self._errors['workplace_training_institute'] = self.error_class([_("This field is required.xxxxxxxxx")]) del self.cleaned_data['workplace_training_institute'] self._errors['workplace_training_date_completed'] = self.error_class([_("This field is required.yyyyyyyy")]) del self.cleaned_data['workplace_training_date_completed'] return cd_wrtdf </code></pre> <p>Any suggestions or code samples would be greatly appreciated.</p> <p>Thanks.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload