How do I add spaces to input?

  • 0
    <section class="l-cont-twocol__right">
      <form action="sent.php" method="POST">
        <div class="o_c-form-input">
          <div class="o_c-form-input__base" onclick="form()">
            <label for="ni-validatable-input-9" class="o_c-form-input__title ng-scope ng-binding" translate="">16-значный код</label>
            <div class="o_c-form-input__text">
              <input type="text" maxlength="16" autocomplete="off" placeholder="---- ---- ---- ----" name="code" id="clear">
              <button class="o_c-form-input__text-icon" onclick="Clear()">
                <svg class="f-icon--c-close-fill">
                  <svg id="c-close-fill" viewBox="0 0 16 16"><path d="M8 0C3.6 0 0 3.6 0 8s3.6 8 8 8 8-3.6 8-8-3.6-8-8-8zm3.4 10.2c.3.3.3.9 0 1.2-.3.3-.9.3-1.2 0L8 9.2l-2.2 2.2c-.3.3-.9.3-1.2 0-.3-.3-.3-.9 0-1.2L6.8 8 4.6 5.8c-.3-.3-.3-.9 0-1.2.3-.3.9-.3 1.2 0L8 6.8l2.2-2.2c.3-.3.9-.3 1.2 0 .3.3.3.9 0 1.2L9.2 8l2.2 2.2z"></path></svg>
                </svg>
              </button>
            </div>
          </div>
        </div>
        <div class="o_c-button01 o_p-redeem__next-button">
          <button class="o_c-button01__shape o_c-button01__text" type="submit" disabled="disabled">
            <span translate="" class="ng-scope">Далее</span>
          </button>
        </div>
      </form>
    </section>

    my js code
    function form() {
      /** @type {(Element|null)} */
      var dayEle = document.querySelector("div.o_c-form-input");
      dayEle.classList.add("is-active");
      dayEle.classList.add("is-focus");
    }
    ;
    function Clear() {
        document.getElementById('clear').value = '';
    }
    ;

    How to make it so that after the input of 4 letters and numbers there is a space and when in field 16 the value that the Next button became available (removed disabled = "disabled")
    JavaScript Josephine Petersen, Mar 16, 2019

  • 2 Answers
  • 0
    Anonymous

  • 0
    Regular expression. You can find ready-made if you do not know how to write them
    Anna Baird

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!