๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
WEB

Input ํƒœ๊ทธ, ์†์„ฑ

by mingzoo 2021. 1. 3.

์˜ค๋Š˜์€ ๊ทธ๋™์•ˆ ๋ฆฌ์•กํŠธ ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•˜๋ฉด์„œ ๋ฌด์ž‘์ • ๋”ฐ๋ผํ•˜๊ธฐ๋งŒ ๋ฐ”๋นด์—ˆ๋Š”๋ฐ, ์ญ‰ ์˜ˆ์ œ๋ฅผ ์ž‘์„ฑํ•ด์˜ค๋ฉด์„œ ๋น ์ง€์ง€์•Š๋Š” ํƒœ๊ทธ๋“ค์ด ์žˆ์—ˆ๋‹ค.

inputํƒœ๊ทธ๊ฐ€ ์ฐธ ๋งŽ์ด ์“ฐ์˜€๋Š”๋ฐ ๊ณ„์† ์“ฐ๋ฉด์„œ ๊ณต๋ถ€๊ฐ€ ๋ถ€์กฑํ•ด์„œ ์ œ๋Œ€๋กœ ์“ฐ์ง€ ๋ชปํ•˜๋Š” ๊ฒƒ ๊ฐ™์•„์„œ ์ข€ ์ฐพ์•„๋ดค๋‹ค.

 

<input
  ref={(ref) => this.input = ref}
  type='password'
  value={this.state.password}
  onChange={this.handleChange}
  className={this.state.clicked ? (this.state.validated ? 'success' : 'failure') : ''}
  onKeyPress={this.onKeyPress}
/>

 

์ด๋ ‡๊ฒŒ input ํƒœ๊ทธ๋ฅผ ์ž‘์„ฑํ• ๋•Œ ํƒœ๊ทธ ์•ˆ์— ์ž‘์„ฑ๋˜๋Š” ์†์„ฑ๋“ค์„ ๋” ๋‹ค์–‘ํ•˜๊ฒŒ ์•Œ๊ณ , ์ž˜ ํ™œ์šฉํ•˜๊ณ  ์‹ถ๋‹ค๋Š” ์ƒ๊ฐ์— ์ฐพ์•„์„œ ์ •๋ฆฌํ•ด๋ณด์•˜๋‹ค.

 

type ์†์„ฑ ๋‚ด์šฉ
text ํ…์ŠคํŠธ ์ž…๋ ฅ ์ฐฝ
password ๋น„๋ฐ€๋ฒˆํ˜ธ ์ž…๋ ฅ ์ฐฝ
radio ์„ ํƒํ•  ์ˆ˜ ์žˆ๋Š” ๋ผ๋””์˜ค ๋ฒ„ํŠผ ์ƒ์„ฑ
checkbox ์ฒดํฌ๋ฐ•์Šค ์ƒ์„ฑ
file ํŒŒ์ผ ์ด๋ฆ„ ์ž…๋ ฅ ์ฐฝ
image ์ด๋ฏธ์ง€๋ฅผ ์ „์†ก ๋ฒ„ํŠผ์œผ๋กœ ๋งŒ๋“ฆ
hidden ์‚ฌ์šฉ์ž์—๊ฒŒ๋Š” ์•ˆ๋ณด์ด์ง€๋งŒ, ์„œ๋ฒ„๋กœ ์ „์†ก
submit ์„œ๋ฒ„๋กœ ์ œ์ถœ, ์ „์†กํ•˜๋Š” ๋ฒ„ํŠผ
button ์ผ๋ฐ˜ ๋ฒ„ํŠผ ์ƒ์„ฑ

 

์ด๋ ‡๊ฒŒ type ์†์„ฑ ์ด์™ธ์— ๋งŽ์€ ์†์„ฑ๋“ค์ด ์กด์žฌํ•œ๋‹ค.

input ํƒœ๊ทธ์— ์‚ฌ์šฉ์ด ๊ฐ€๋Šฅํ•œ ๋‹ค๋ฅธ ์†์„ฑ๋“ค!

์š”์ฆ˜ ๋ฆฌ์•กํŠธ๋ฅผ ๊ณต๋ถ€ํ•  ๋•Œ ํ•ด๋ณด๋Š” ์˜ˆ์ œ๋“ค์— ๋ณดํ†ต type, value ๋“ฑ์˜ ์†์„ฑ๋“ค์€ ๋น ์ง์—†์ด ๋‚˜์˜ค๊ณ  ์žˆ๋‹ค.

 

์†์„ฑ ๋‚ด์šฉ
value ์ „์†กํ•  ์ž…๋ ฅ๊ฐ’ ์ง€์ •
title ๋งˆ์šฐ์Šค๋ฅผ ์˜ฌ๋ ธ์„ ๋•Œ ๋‚˜ํƒ€๋‚  ๋ฉ”์‹œ์ง€
readonly ํ‚ค๋ณด๋“œ๋กœ ์ˆ˜์ • ๋ถˆ๊ฐ€
required ๋ฐ˜๋“œ์‹œ ์ž…๋ ฅ๋˜์–ด์•ผ form ์ „์†ก
step numberํƒ€์ž…์— ๊ฐ„๊ฒฉ์„ ์ง€์ •
disabled ์„ ํƒ์ด๋‚˜ ์ˆ˜์ •์ด ๋ถˆ๊ฐ€๋Šฅํ•œ ์ƒํƒœ

 

์ด๋Ÿฐ ํƒœ๊ทธ๋“ค ๋ง๊ณ  ๋˜ ์“ฐ์ด๊ณ  ๋ฐœ๊ฒฌ๋˜๋Š” ์†์„ฑ๋“ค์ด ์žˆ์œผ๋ฉด ์ถ”๊ฐ€ํ•ด์„œ ๊ณ„์† ๋ˆˆ์— ์ตํ˜€๋†”์•ผ๊ฒ ๋‹ค!

728x90