@PyChan

Как добавить один обработчик jquery к двум полям django ModelForm?

Обработчик:
$(document).ready(function() {
   $('#id_repeat_password').on('keyup', function(){
      var Value = $('#id_repeat_password').val();
      var Value1 = $('#id_password').val();
      if (Value != Value1)
      {
        $("#text").animate({opacity: "1"}, "fast");
      }
      else
      {
        $("#text").animate({opacity: "0"}, "fast");
      }
   });
});

Форма
class SignUp(forms.Form):
    username = CharField(label='username', max_length=150,
                         widget=TextInput(attrs={'required': True, "class": 'input', 'type': "text"}))
    email = CharField(label='Username', max_length=150,
                      widget=TextInput(attrs={'required': True, "class": 'input', 'type': "text"}))
    password = CharField(label='Password', max_length=150,
                         widget=TextInput(attrs={'required': True, "class": 'input', 'type': "password"}))
    repeat_password = CharField(label='Repeat your password', max_length=150,
                                widget=TextInput(attrs={'required': True, "class": 'input', 'type': "password"}))

Нужно чтобы обработчик вызывался и при вводе в поле password, и при вводе в поле repeat_password. Подскажите, пожалуйста, как это сделать
  • Вопрос задан
  • 24 просмотра
Решения вопроса 1
bootd
@bootd
Гугли и ты откроешь врата знаний!
$('[type="password"]')
// Или дать класс этим полям
$('.inputPassword')
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы