Lecture

input μž…λ ₯ νƒœκ·Έ 심화

<form>κ³Ό ν•¨κ»˜ μ‚¬μš©ν•˜λŠ” <input />

input νƒœκ·ΈλŠ” λŒ€λΆ€λΆ„ <form>(양식폼) νƒœκ·Έμ™€ ν•¨κ»˜ μ‚¬μš©ν•©λ‹ˆλ‹€.

예λ₯Ό λ“€μ–΄ νšŒμ›κ°€μž… ν™”λ©΄μ—μ„œ input νƒœκ·Έλ‘œ μ‚¬μš©μžμ—κ²Œ 데이터λ₯Ό μž…λ ₯을 λ°›κ³ , <form> νƒœκ·Έλ‘œ μž…λ ₯ 받은 데이터λ₯Ό μ„œλ²„μ— μ „μ†‘ν•©λ‹ˆλ‹€.

form νƒœκ·Έ ν™œμš© μ˜ˆμ‹œ
<form action="/submit" method="post"> <input type="text" name="username" placeholder="μ‚¬μš©μž 이름" /> <input type="password" name="password" placeholder="λΉ„λ°€λ²ˆν˜Έ" /> <input type="submit" value="제좜" /> </form>

μž…λ ₯폼에 λŒ€ν•œ 더 μžμ„Έν•œ λ‚΄μš©μ€ λ‹€μŒ μˆ˜μ—…μ—μ„œ 닀루도둝 ν•˜κ² μŠ΅λ‹ˆλ‹€.


label νƒœκ·Έ ν™œμš©

label νƒœκ·ΈλŠ” input μž…λ ₯λž€μ˜ μ„€λͺ…μ΄λ‚˜ 제λͺ©μ„ λ‚˜νƒ€λƒ…λ‹ˆλ‹€.

label νƒœκ·Έλ₯Ό μ‚¬μš©ν•  λ•ŒλŠ” input νƒœκ·Έμ˜ id 속성과 label νƒœκ·Έμ˜ for 속성을 같은 κ°’μœΌλ‘œ 지정해야 ν•©λ‹ˆλ‹€.

label νƒœκ·Έ μ˜ˆμ‹œ
<label for="username">μ‚¬μš©μž 이름:</label> <input type="text" id="username" name="username" />

μœ νš¨μ„± 검사 (Validation)

μœ νš¨μ„± κ²€μ‚¬λŠ” μž…λ ₯된 정보가 μ˜¬λ°”λ₯Έμ§€ ν™•μΈν•˜λŠ” 것을 λœ»ν•©λ‹ˆλ‹€.

μ•„λž˜ input은 required 속성을 μ‚¬μš©ν•΄ input이 값을 κ°–κ³  μžˆλŠ”μ§€ μœ νš¨μ„±μ„ κ²€μ‚¬ν•©λ‹ˆλ‹€.

required ν™œμš© μœ νš¨μ„± 검사
<input type="email" name="useremail" required />
Mission
0 / 1

input νƒœκ·Έμ™€ ν•¨κ»˜ μœ νš¨μ„± 검사λ₯Ό μœ„ν•΄ μ‚¬μš©ν•  수 μžˆλŠ” 속성은 λ¬΄μ—‡μΈκ°€μš”?

readonly

disabled

required

hidden

Lecture

AI Tutor

Publish

Design

Upload

Notes

Favorites

Help