๐Ÿ“Web Developing/HTML ๊ธฐ์ดˆ

input ํƒœ๊ทธ-6 (์ฃผ์š” ์†์„ฑ๋“ค)

Hush 2022. 5. 30. 17:49

input ํƒœ๊ทธ์— ์—ฌ๋Ÿฌ ์ž์ž˜ํ•œ ๊ธฐ๋Šฅ๋“ค์„ ์ถ”๊ฐ€ํ•  ์ˆ˜ ์žˆ๋Š” ์†์„ฑ๋“ค์„ ์•Œ์•„๋ณด์ž

autofocus : ์ž๋™์œผ๋กœ ์ปค์„œ ๊ฐ€์ ธ๋‹ค๋†“๊ธฐ

์ด ์†์„ฑ์„ ์‚ฌ์šฉํ•˜๋ฉด ํŽ˜์ด์ง€๋ฅผ ๋ถˆ๋Ÿฌ์˜ค์ž๋งˆ์ž ์›ํ•˜๋Š” ์š”์†Œ์— ๋งˆ์šฐ์Šค ํฌ์ธํ„ฐ๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค.

<input type=ํ…์ŠคํŠธ์ž…๋ ฅํ•„๋“œ autofocus>

 

placeholder : ํžŒํŠธ ํ‘œ์‹œ

ํ…์ŠคํŠธ๋ฐ•์Šค์— ์ ๋‹นํ•œ ํžŒํŠธ ๋‚ด์šฉ์„ ํ‘œ์‹œํ•˜๊ณ , ํž๋“œ๋ฅผ ํด๋ฆญํ•˜๋ฉด ํžŒํŠธ๊ฐ€ ์‚ฌ๋ผ์ง€๋„๋ก ํ•  ์ˆ˜ ์žˆ๋‹ค.

'์•„์ด๋””๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”' ๋“ฑ์˜ ํžŒํŠธ๋ฅผ ๋กœ๊ทธ์ธ ํ…์ŠคํŠธ๋ฐ•์Šค์— ํ‘œ์‹œํ•˜๋Š” ๊ฒƒ์ด ๊ทธ ์˜ˆ์‹œ์ด๋‹ค.

<input type=ํ…์ŠคํŠธ์ž…๋ ฅํ•„๋“œ placeholder="ํžŒํŠธ๋‚ด์šฉ">

autofocus์™€ placeholder๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ์˜ˆ์ œ์ด๋‹ค

<!DOCTYPE html>
<html lang="ko">
    <head>
        <meta charset="utf-8">  
        <title>Html-basic</title>
    </head>
    <body>
        <form action="">
            <fieldset>
                <legend>๋ฐฐ์†ก ์ •๋ณด</legend>
                <label for="">์ด๋ฆ„<input type="text" autofocus></label><br>
                <label for="">๋ฐฐ์†ก ์ฃผ์†Œ<input type="text"></label><br>
                <label for="">์ด๋ฉ”์ผ<input type="email" name="" id=""></label><br>
                <label for="">์—ฐ๋ฝ์ฒ˜<input type="tel" name="" id="" placeholder="ํ•˜์ดํ”ˆ ๋บด๊ณ  ์ž…๋ ฅํ•ด ์ฃผ์„ธ์š”"></label><br>
                <label for="">๋ฐฐ์†ก ์ง€์ •<input type="date" name="" id="">(์ฃผ๋ฌธ์ผ๋กœ๋ถ€ํ„ฐ ์ตœ์†Œ 3์ผ ์ดํ›„)</label>
            </fieldset>
        </form>
    </body>
</html>

 

readonly : ์ฝ๊ธฐ ์ „์šฉ ํ•„๋“œ

์ž…๋ ฅ์€ ๋ชปํ•˜๊ณ  ์ฝ๊ฒŒ๋งŒ ํ•˜๋Š” ์ฝ๊ธฐ ์ „์šฉ ํ•„๋“œ๋ฅผ ๋งŒ๋“ค ์ˆ˜ ์žˆ๋‹ค.

<input type=ํ…์ŠคํŠธ์ž…๋ ฅํ•„๋“œ readonly>

 

required : ํ•„์ˆ˜ ์ž…๋ ฅ ํ•„๋“œ

submit ๋ฒ„ํŠผ์ด ํด๋ฆญ๋˜์—ˆ์„ ๋•Œ required์†์„ฑ์ด ์žˆ๋Š” ํ•„๋“œ๋Š” ๋‚ด์šฉ์ด ์ฑ„์›Œ์ ธ์žˆ๋Š”์ง€ ๊ฒ€์‚ฌ๋ฉ๋‹ˆ๋‹ค.

๋งŒ์•ฝ ํ•„์ˆ˜ ํ•„๋“œ๋ฅผ ์ฒด์šฐ์ง€ ์•Š๊ณ  submit ๋ฒ„ํŠผ์„ ๋ˆ„๋ฅผ ๊ฒฝ์šฐ, ์ œ์ถœ์ด ๋˜์ง€ ์•Š๊ณ  ๊ฒฝ๊ณ ๋ฉ”์„ธ์ง€๊ฐ€ ๋‚˜์˜ต๋‹ˆ๋‹ค.

<input type=ํ…์ŠคํŠธ์ž…๋ ฅํ•„๋“œ required>

readonly์™€ required ์†์„ฑ์„ ์‚ฌ์šฉํ•˜๋Š” ์˜ˆ์ œ์ด๋‹ค

<!DOCTYPE html>
<html lang="ko">
    <head>
        <meta charset="utf-8">  
        <title>Html-basic</title>
    </head>
    <body>
        <form action="">
            <fieldset>
                <legend>๋ฐฐ์†ก ์ •๋ณด</legend>
                <label for="">์ด๋ฆ„<input type="text" value="HUSH" readonly></label><br>
                <label for="">๋ฐฐ์†ก ์ฃผ์†Œ<input type="text" required></label><br>
                <label for="">์ด๋ฉ”์ผ<input type="email" name="" id=""></label><br>
                <label for="">์—ฐ๋ฝ์ฒ˜<input type="tel" name="" id="" placeholder="ํ•˜์ดํ”ˆ ๋บด๊ณ  ์ž…๋ ฅํ•ด ์ฃผ์„ธ์š”"></label><br>
                <label for="">๋ฐฐ์†ก ์ง€์ •<input type="date" name="" id="">(์ฃผ๋ฌธ์ผ๋กœ๋ถ€ํ„ฐ ์ตœ์†Œ 3์ผ ์ดํ›„)</label>
                <input type="submit" value="์ œ์ถœํ•˜๊ธฐ">
            </fieldset>
        </form>
    </body>
</html>