๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๊ฐœ์ธ๊ณต๋ถ€/HTML5 + CSS3

[HTML+CSS][ํผ ๊ด€๋ จ ํƒœ๊ทธ๋“ค] 03 - <input> ํƒœ๊ทธ์˜ ๋‹ค์–‘ํ•œ ์†์„ฑ

by ๐Ÿ‡๋ฐ•๋ด‰๋ด‰๐Ÿ‡ 2020. 6. 18.

 

 

[HTML+CSS][ํผ ๊ด€๋ จ ํƒœ๊ทธ๋“ค] 02 - ์‚ฌ์šฉ์ž ์ž…๋ ฅ์„ ์œ„ํ•œ

ํƒœ๊ทธ

[HTML+CSS][ํผ ๊ด€๋ จ ํƒœ๊ทธ๋“ค] 01 - ํผ(form) [HTML+CSS] [์ด๋ฏธ์ง€์™€ ํ•˜์ดํผ๋งํฌ] 03 - SVG ์ด๋ฏธ์ง€ [HTML+CSS] [์ด๋ฏธ์ง€์™€ ํ•˜์ดํผ๋งํฌ] 02 - ๋งํฌ ํƒœ๊ทธ [HTML+CSS] [์ด๋ฏธ์ง€์™€ ํ•˜์ดํผ๋งํฌ] 01 - ์ด๋ฏธ์ง€ ํƒœ๊ทธ [HTML+CSS]..

onelight-stay.tistory.com

 

<input> ํƒœ๊ทธ์˜ ํผ์„ ๋งŒ๋“œ๋Š” ๊ธฐ๋ณธ์ ์ธ ๊ฒƒ์— ๋Œ€ํ•ด์„œ ์•Œ์•˜์œผ๋‹ˆ

ํ•„๋“œ๋ฅผ ์ข€ ๋” ์„ธ๋ฐ€ํ•˜๊ฒŒ ์กฐ์ •ํ•˜๋Š” ๊ฒƒ์— ๋Œ€ํ•ด์„œ ๋ฐฐ์›Œ๋ณด์ž.

 

 


 

 

- autofocus ์†์„ฑ -

 

ํ•ด๋‹น ์†์„ฑ์„ ์‚ฌ์šฉํ•  ๊ฒฝ์šฐ ํŽ˜์ด์ง€๋ฅผ ๋ถˆ๋Ÿฌ์˜ค์ž๋งˆ์ž

ํผ์˜ ์š”์†Œ ์ค‘์—์„œ ์›ํ•˜๋Š” ์š”์†Œ์— ๋งˆ์šฐ์Šค ์ปค์„œ๋ฅผ ํ‘œ์‹œํ•  ์ˆ˜ ์žˆ๋‹ค.

 

 

    <form action="register.php" method="POST">
        <h1>์—ฌ๋ฆ„๋ฐฉํ•™ ํŠน๊ฐ• ์‹ ์ฒญ</h1>
        <fieldset>
            <legend>์ˆ˜๊ฐ•๊ณผ๋ชฉ</legend>
            <ul>
                <li>
                    <label class="reg">์˜์–ดํšŒํ™”(์ดˆ๊ธ‰) <input type="text" value="์˜ค์ „ 9:00~11:00"></label>
                </li>
            </ul>
        </fieldset>
        <fieldset>
            <legend>์‹ ์ฒญ์ž</legend>
            <ul>
                <li>
                    <label class="reg" for="uname">์ด๋ฆ„</label>
                    <input type="text" id="uname" autofocus required>
                </li>
                <li>
                    <label class="reg" for="unum">ํ•™๋ฒˆ</label>
                    <input type="text" id="unum" required>
                </li>
                <li>
                    <label class="reg" for="usub">ํ•™๊ณผ</label>
                    <input type="text" id="usub" required>
                </li>
            </ul>
        </fieldset>
        <br>
        <input type="submit" value="์‹ ์ฒญํ•˜๊ธฐ">
    </form>

 

 


 

 

- placeholder ์†์„ฑ -

 

์‚ฌ์šฉ์ž๊ฐ€ ํ…์ŠคํŠธ๋ฅผ ์ž…๋ ฅํ•  ๋•Œ ๋„์›€์ด ๋˜๋„๋ก

์ž…๋ ฅ๋ž€์— ์ ๋‹นํ•œ ์ •๋ณด๋‚˜ ํžŒํŠธ ๋‚ด์šฉ์„ ํ‘œ์‹œํ•˜๊ณ 

๋‚ด์šฉ์„ ์ž…๋ ฅํ•˜๊ธฐ ์œ„ํ•ด ํ•„๋“œ๋ฅผ ํด๋ฆญํ•  ๊ฒฝ์šฐ

๋‚ด์šฉ์ด ์‚ฌ๋ผ์ง€๋„๋ก ์„ค์ •ํ•œ๋‹ค.

 

 

    <form action="register.php" method="POST">
        <fieldset>
            <legend>์‹ ์ฒญ์ž</legend>
            <ul>
                <li>
                    <label class="reg" for="uname">์ด๋ฆ„</label>
                    <input type="text" id="uname" required>
                </li>
                <li>
                    <label class="reg" for="unum">ํ•™๋ฒˆ</label>
                    <input type="text" id="unum" placeholder="ํ•˜์ดํ‘ผ ์—†์ด ์ž…๋ ฅ" required>
                </li>
                <li>
                    <label class="reg" for="usub">ํ•™๊ณผ</label>
                    <input type="text" id="usub" required>
                </li>
            </ul>
        </fieldset>
        <br>
        <input type="submit" value="์‹ ์ฒญํ•˜๊ธฐ">
    </form>

 

 


 

 

- readonly ์†์„ฑ -

 

์ฝ๊ธฐ ์ „์šฉ ํ•„๋“œ๋กœ ํ…์ŠคํŠธ ๋ž€์„ ์‚ฌ์šฉ์ž๊ฐ€ ์ž…๋ ฅํ•˜์ง€ ๋ชปํ•˜๊ณ 

์ฝ๊ฒŒ๋งŒ ๋งŒ๋“ค ์ˆ˜ ์žˆ๊ฒŒ ํ•„๋“œ๋ฅผ ์ฝ๊ธฐ ์ „์šฉ์œผ๋กœ ๋ฐ”๊ฟ”์ค€๋‹ค.

 

 

    <form>
        <fieldset>
            <legend>์ˆ˜๊ฐ•๊ณผ๋ชฉ</legend>
            <ul>
                <li>
                    <label class="reg" for="subject">์˜์–ดํšŒํ™”(์ดˆ๊ธ‰)</label>
                    <input type="text" id="subject" value="์˜ค์ „ 09:00~11:00" readonly>
                </li>
            </ul>
        </fieldset>
    </form>

 

 


 

 

- required ์†์„ฑ -

 

๋‚ด์šฉ์„ ํผ์— ์ž…๋ ฅํ•œ ํ›„ submit ๋ฒ„ํŠผ์„ ํด๋ฆญํ•ด์„œ ์„œ๋ฒ„๋กœ ๋‚ด์šฉ์„ ์ „์†กํ•˜๊ธฐ ์ „์—

ํ•„์ˆ˜ ํ•„๋“œ์— ํ•„์š”ํ•œ ๋‚ด์šฉ์ด ๋ชจ๋‘ ์ฑ„์›Œ์กŒ๋Š”์ง€ ๊ฒ€์‚ฌํ•˜๋Š” ์†์„ฑ์ด๋‹ค.

 

 

    <form action="register.php" method="POST">
        <fieldset>
            <legend>์‹ ์ฒญ์ž</legend>
            <ul>
                <li>
                    <label class="reg" for="uname">์ด๋ฆ„</label>
                    <input type="text" id="uname" required>
                </li>
                <li>
                    <label class="reg" for="unum">ํ•™๋ฒˆ</label>
                    <input type="text" id="unum" placeholder="ํ•˜์ดํ‘ผ ์—†์ด ์ž…๋ ฅ" required>
                </li>
                <li>
                    <label class="reg" for="usub">ํ•™๊ณผ</label>
                    <input type="text" id="usub" required>
                </li>
            </ul>
        </fieldset>
        <br>
        <input type="submit" value="์‹ ์ฒญํ•˜๊ธฐ">
    </form>

 

 


 

 

- min, max, step ์†์„ฑ -

 

min - ํ•ด๋‹น ํ•„๋“œ์˜ ์ตœ์†Ÿ๊ฐ’

 

max - ํ•ด๋‹น ํ•„๋“œ์˜ ์ตœ๋Œ“๊ฐ’

 

step - ํ—ˆ์šฉ๋œ ๋ฒ”์œ„ ๋‚ด์˜ ์ผ์ •ํ•œ ์ˆซ์ž ๊ฐ„๊ฒฉ

 

date, datetime, datetime-local, month, week, time, number, range ๊ฒฝ์šฐ์— ์‚ฌ์šฉ ๊ฐ€๋Šฅ

 

 

    <form>
        <fieldset>
            <legend>๊ต์žฌ ์ฃผ๋ฌธ</legend>
            <ul>
                <li>
                    <label class="reg" for="subject2">๊ต์žฌ</label>
                    <input type="number" id="subject2" min="1" value="1">
                </li>
                <li>
                    <label class="reg" for="workst">์›Œํฌ์‹œํŠธ</label>
                    <input type="number" id="workst" min="1" value="1">
                </li>
                <li>
                    <label class="reg" for="group">๋‹จ์ฒด์ฃผ๋ฌธ</label>
                    <input type="number" id="group" min="10" max="100" value="10" step="10">
                </li>
            </ul>
        </fieldset>
    </form>

 

 


 

 

- size, minlength, maxlength ์†์„ฑ -

 

size - ํ™”๋ฉด์— ๋ช‡ ๊ธ€์ž๋ฅผ ๋ณด์ด๊ฒŒ ํ• ์ง€ ์ง€์ •

 

minlength - ์ตœ๋Œ€ ๊ฐ€๋Šฅ ์ž…๋ ฅ ๊ธ€์ž ์ˆ˜ ์ง€์ •

 

maxlength - ์ตœ์†Œ ๊ฐ€๋Šฅ ์ž…๋ ฅ ๊ธ€์ž ์ˆ˜ ์ง€์ •

 

 

    <form action="register.php" method="POST">
        <h1>ํšŒ์› ๊ฐ€์ž…์„ ํ™˜์˜ํ•ฉ๋‹ˆ๋‹ค</h1>
        <ul>
            <li>
                <label>์•„์ด๋””: <input type="text" id="u-id" size="10" minlength="4" maxlength="15"></label>
                <small style="color: red;">4~15์ž๋ฆฌ ์ด๋‚ด์˜ ์˜๋ฌธ๊ณผ ์ˆซ์ž</small>
            </li>
            <li>
                <label>์ด๋ฉ”์ผ: <input type="email" id="u-email"></label>
            </li>
            <li>
                <label>๋น„๋ฐ€๋ฒˆํ˜ธ: <input type="password" id="u-pwd"></label>
            </li>
            <li>
                <label>๋น„๋ฐ€๋ฒˆํ˜ธ ํ™•์ธ: <input type="password" id="u-pwd2"></label>
            </li>
            <input type="submit" value="ํšŒ์›๊ฐ€์ž…">
        </ul>
    </form>

 

 


 

 

- ๊ทธ ๋ฐ–์˜ ์†์„ฑ -

 

 

 


 

 

๊ฐ„๋‹จํ•œ ์†์„ฑ๋“ค์ด์ง€๋งŒ ํ•ด๋‹น ์†์„ฑ๋“ค์„ ์‚ฌ์šฉํ•˜๊ณ  ๋‚˜๋ฉด

ํŽ˜์ด์ง€๊ฐ€ ํ›จ์”ฌ ์•„๊ธฐ์ž๊ธฐํ•˜๊ณ  ๋” ๊ณ ๊ธ‰์ง„ ๋Š๋‚Œ์ด๋‹ค.

 

์ž˜ ํ™œ์šฉํ•ด์„œ ์จ๋จน์–ด์•ผ๊ฒ ๋‹ค.

 

 


 

 

< ์ฐธ๊ณ  >

Do it! HTML5+CSS3 ์›น ํ‘œ์ค€์˜ ์ •์„

 

 

โ€ป ํ•ด๋‹น ๊ธ€์€ ์Šต๋“ ๋ชฉ์ ์œผ๋กœ ์ž‘์„ฑ๋œ ๊ธ€์ž…๋‹ˆ๋‹ค โ€ป

 

๋ฐ˜์‘ํ˜•

๋Œ“๊ธ€