본인확인번호 6자리 마크업

본인확인번호 6자리 마크업

QA

본인확인번호 6자리 마크업

본문

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

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

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

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

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

 

32936023_1728553210.5436.png

이 질문에 댓글 쓰기 :

답변 1

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

 

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

 

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

 

mark_up.html
​​​​
<!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;
    }
    .code-input {
      width: 40px;
      height: 40px;
      font-size: 24px;
      text-align: center;
    }
    button {
      margin-top: 20px;
      padding: 10px 20px;
      font-size: 18px;
      cursor: not-allowed;
    }
    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>
  <script>
    const inputs = document.querySelectorAll(".code-input");
    inputs.forEach((input, index) => {
      input.addEventListener("input", (event) => {
        if (event.target.value.length === 1 && index < inputs.length - 1) {
          inputs[index + 1].focus();
        }
        checkFilledInputs();
      });
      input.addEventListener("keydown", (event) => {
        if (event.key === "Backspace" && input.value.length === 0 && index > 0) {
          inputs[index - 1].focus();
        }
      });
    });
    function checkFilledInputs() {
      const allFilled = [...inputs].every(input => input.value.length === 1);
      document.getElementById("submit").disabled = !allFilled;
    }
  </script>
</body>
</html>

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

 

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

답변을 작성하시기 전에 로그인 해주세요.
전체 1,123
QA 내용 검색
filter #html ×

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT