Skip to content

Latest commit

Β 

History

History
73 lines (66 loc) Β· 2.22 KB

html23.md

File metadata and controls

73 lines (66 loc) Β· 2.22 KB

[HTML μ œλŒ€λ‘œ λ°°μ›Œ 볼래?] Ep#23-Input Types μš”μ†Œμ˜ 속성 μ•Œμ•„λ³΄κΈ°

Input Type 속성

<!DOCTYPE html>
<html>
  <head>
    <title>Document</title>
  </head>
  <body>
    <form action="">
      <input type="tel" pattern="[0-9]{3}-[0-9]{4}-[0-9]{4}" />
      <div>
        아이디
        <input type="text" pattern="" autofocus />
      </div>
      <div>
        λΉ„λ°€λ²ˆν˜Έ
        <input type="text" />
      </div>
      <!-- <div>
        <input
          type="text"
          value=""
          maxlength="8"
          style="width: 100%"
          placeholder="010-0000-0000 ν˜•μ‹μœΌλ‘œ μž…λ ₯ν•˜μ„Έμš”."
          required
        />
      </div> -->
      <div>
        <input type="text" value="ABC" readonly />
      </div>
      <div>
        <input type="text" value="ABC" disabled />
      </div>
      <input type="submit" value="μ €μž₯" />
    </form>
    <script></script>
  </body>
</html>

[Note]

  • input type 속성 (곡톡적인 속성)
    • value; κΈ°λ³Έκ°’ μ„€μ • κ°€λŠ₯
      • μ‚¬μš©μžκ°€ μž…λ ₯ κ°’ μˆ˜μ • μ‹œ value 속성 κ°’ 변경됨
    • readonly; μˆ˜μ • λΆˆκ°€ (focus λΆˆκ°€), 읽기만 ν—ˆμš©
      • form νƒœκ·Έ λ‚΄λΆ€μ—μ„œ submit μ‚¬μš© μ‹œ νŠΉμ • URL둜 value κ°’ λ„˜μ–΄μ˜΄
    • disabled; 색상 μžμ²΄κ°€ gray μƒ‰μƒμœΌλ‘œ 변경됨
      • form νƒœκ·Έ λ‚΄λΆ€μ—μ„œ submit μ‚¬μš© μ‹œ νŠΉμ • URL둜 value κ°’ λ„˜μ–΄κ°€μ§€ μ•ŠμŒ
    • maxlength; μž…λ ₯ 자릿수 μ œν•œ
    • placeholder; μž…λ ₯값에 λŒ€ν•œ κ°€μ΄λ“œ 제곡
    • required; λ°˜λ“œμ‹œ μž…λ ₯ν•΄μ•Ό 함 (form νƒœκ·Έ λ‚΄λΆ€μ—μ„œ submit μ‹œ)
    • autofocus
      • 둜그인 ν™”λ©΄ 같은 경우 무쑰건 ID λ¨Όμ € focus λ˜μ–΄μ•Ό 함
      • ꡳ이 마우슀둜 focus 이동할 ν•„μš” μ—†μŒ
    • autocomplete="on"
      • νŠΉμ • 값이 λΈŒλΌμš°μ € μΊμ‹œμ— 이미 μ €μž₯λ˜μ–΄ 있으면 λ°”λ‘œ λ³΄μž„
      • μ€‘μš”ν•œ 값듀을 λΈŒλΌμš°μ €κ°€ κΈ°μ–΅ν•˜λ©΄ λ³΄μ•ˆμƒ 문제 생길 수 있음
    • pattern
      • JS의 μ •κ·œμ‹ μ•Œμ•„μ•Ό μ‚¬μš© κ°€λŠ₯
      • μ „ν™”λ²ˆν˜Έ 3-4-4 μžλ¦Ώμˆ˜μ™€ κ°€λŠ₯ 숫자 μ œν•œ
  • div νƒœκ·Έ; ν™”λ©΄μ˜ λ ˆμ΄μ•„μ›ƒ ꡬ도 λ§Œλ“€κΈ° μœ„ν•΄ μ‚¬μš© (블둝 μš”μ†Œ)
    • μ–΄λ–€ νƒœκ·Έλ“ μ§€ 담을 수 있음

Reference