Показать сообщение отдельно
  #8 (permalink)  
Старый 15.03.2014, 18:08
Аватар для рони
Профессор
Отправить личное сообщение для рони Посмотреть профиль Найти все сообщения от рони
 
Регистрация: 27.05.2010
Сообщений: 33,064

ArtemKrass,
<!DOCTYPE HTML>

<html>

<head>
  <title>Untitled</title>
  <meta charset="utf-8">
  <script type='text/javascript' src='http://code.jquery.com/jquery-1.9.1.js'></script>
<script type='text/javascript'>
 $(function () {
      $("body").on('input', '#1:not(.disabled)',
          function () {
              if (this.value.length > 0) {
                  $('#2').addClass('disabled').prop("readonly", true);
              } else $('#2').removeClass('disabled').prop("readonly", false);
              jQuery('#2').val(this.value)
          }

      ).on('input', '#2:not(.disabled)', function () {
          alert('Hello');
      });
  });
</script>
</head>

<body>
<input type="text" id="1" name="1" value="" size="12" maxlength="10" class="form-text required">
        <br />
<input type="text" id="2" name="2" value="" size="12" maxlength="10" class="form-text required">
</body>

</html>
Ответить с цитированием