테스트 사이트 - 개발 중인 베타 버전입니다

본인확인번호 6자리 마크업 채택완료

웹프리죤 1년 전 조회 4,206

이거 한 자리씩 입력 되는 html 마크업 어떻게 하는거죠..?

그러고보니 이 때까지 퍼블 하면서 이 부분은 인증 이슈다 보니 개발단계에서 진행 햇던 부분으로

html 마크업을 언제 해본적이 있던가 기억도 안나네요..

숫자 입력하면 한 자리씩 채워지는겁니다.

요즘 앱 로그인시 기본으로 사용되는...

 

http://sir.kr/data/editor/2410/32936023_1728553210.5436.png" width="350" />

댓글을 작성하려면 로그인이 필요합니다.

답변 1개

채택된 답변
+20 포인트
glitter0gim
1년 전

※ CSS, JavaScript 코드를 사용한 HTML로 만들 수 있을 것입니다.

 

>>> 만들어진 HTML을 브라우저로 열면 숫자를 한 자리씩 입력할 수 있고,

 

    모든 입력이 완료되면  "확인" 버튼이 활성화되는 폼이 생성 됩니다.

 

mark_up.html

<span style="font-size: 0.875em;">​​​​</span></p>

<p><!DOCTYPE html>

<html lang="ko">

<head>

  <meta charset="UTF-8">

  <meta name="viewport" content="width=device-width, initial-scale=1.0">

  <title>Verification Input</title>

  <style>

    .verification-input {

      display: flex;

      gap: 10px;

    }</p>

<p>    .code-input {

      width: 40px;

      height: 40px;

      font-size: 24px;

      text-align: center;

    }</p>

<p>    button {

      margin-top: 20px;

      padding: 10px 20px;

      font-size: 18px;

      cursor: not-allowed;

    }</p>

<p>    button:enabled {

      cursor: pointer;

      background-color: #4CAF50;

      color: white;

    }

  </style>

</head>

<body>

  <div class="verification-input">

    <input type="text" maxlength="1" class="code-input" />

    <input type="text" maxlength="1" class="code-input" />

    <input type="text" maxlength="1" class="code-input" />

    <input type="text" maxlength="1" class="code-input" />

    <input type="text" maxlength="1" class="code-input" />

    <input type="text" maxlength="1" class="code-input" />

  </div>

  <button id="submit" disabled>확인</button></p>

<p>  <script>

    const inputs = document.querySelectorAll(".code-input");</p>

<p>    inputs.forEach((input, index) => {

      input.addEventListener("input", (event) => {

        if (event.target.value.length === 1 && index < inputs.length - 1) {

          inputs[index + 1].focus();

        }

        checkFilledInputs();

      });</p>

<p>      input.addEventListener("keydown", (event) => {

        if (event.key === "Backspace" && input.value.length === 0 && index > 0) {

          inputs[index - 1].focus();

        }

      });

    });</p>

<p>    function checkFilledInputs() {

      const allFilled = [...inputs].every(input => input.value.length === 1);

      document.getElementById("submit").disabled = !allFilled;

    }

  </script>

</body>

</html></p>

<p>

>>> 브라우저의 요청을 받으면 숫자를 한 자리씩 입력할 수 있고,

 

    모든 입력이 완료되면  [확인]  버튼이 활성화되는 폼이 열립니다.

로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인