천

textarea 글자수 카운트 입니다.

index.html

<!DOCTYPE html>
<html xmlns='http://www.w3.org/1999/xhtml'>
    <head>
        <title>Input Counter</title>
        <meta http-equiv="content-type" content="text/html; charset=utf-8" />
        <link href="stylesheet.css" media="screen" rel="stylesheet" type="text/css" />
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js" type="text/javascript"></script>
        <script src="application.js" type="text/javascript"></script>
    </head>
    <body>
        <div id="container">
            <form action="index.html" method="POST">
                <textarea></textarea>
                <span class="input-counter"></span>
                <input type="submit" id="input-submit" value="등록" />
            </form>
        </div>
    </body>
</html>


stylesheet.js

body {
    font-size: 12px;
    background: #FFF;
    color: #333;
    margin: 0;
}

#container {
    margin: 10px auto;
    width: 500px;
    padding: 10px;
    background: #CCC;
}

form {
    overflow: hidden;
    height: 100%;
}

textarea {
    display: block;
    width: 99%;
    height: 5.0em;
    margin-bottom: 0.5em;
}

span.input-counter {
    float: left;
    font-weight: bold;
    color: #000;
}

span.input-counter.disabled {
    color: #F00;
}

input#input-submit {
    float: right;
}


application.js

$(function() {
    var maxLength = 140;

    function updateInputCount() {
        var textLength = $('textarea').val().length;
        var count = maxLength - textLength;
        $('span.input-counter').text(count);
        if (count < 0) {
            $('span.input-counter').addClass('disabled');
            $('input#input-submit').prop('disabled', true);
        } else {
            $('span.input-counter').removeClass('disabled');
            $('input#input-submit').prop('disabled', false);
        }
    }

    $('textarea')
        .focus(updateInputCount)
        .blur(updateInputCount)
        .keypress(updateInputCount);
    window.setInterval(updateInputCount, 100);

    updateInputCount();
});

|

댓글 1개

댓글을 작성하시려면 로그인이 필요합니다.

프로그램

8,188건
+
제목 글쓴이 날짜 조회
16-06-11 조회 3,051
16-05-12 조회 3,308
16-04-12 조회 3,191
16-02-03 조회 2,944
16-02-03 조회 2,991
16-02-02 조회 3,287
16-02-01 조회 2,672
16-02-01 조회 2,648
16-01-31 조회 2,678
16-01-31 조회 2,684
16-01-31 조회 2,701
16-01-30 조회 2,688
16-01-29 조회 2,685
16-01-29 조회 2,576
16-01-29 조회 2,561
16-01-28 조회 2,510
16-01-28 조회 2,419
16-01-27 조회 2,573
16-01-27 조회 2,563
16-01-26 조회 2,549
16-01-25 조회 2,621
16-01-25 조회 2,493
16-01-24 조회 2,493
16-01-24 조회 2,485
16-01-24 조회 2,412
16-01-23 조회 2,461
16-01-23 조회 2,477
16-01-23 조회 2,449
16-01-22 조회 2,681
16-01-21 조회 2,714
16-01-21 조회 2,576
16-01-21 조회 2,544
16-01-20 조회 2,493
16-01-20 조회 2,446
16-01-20 조회 2,457
16-01-19 조회 2,484
16-01-19 조회 2,548
16-01-18 조회 2,532
16-01-16 조회 2,467
16-01-16 조회 2,396
16-01-16 조회 2,453
16-01-15 조회 2,610
16-01-15 조회 2,612
16-01-15 조회 2,532
16-01-15 조회 2,465
16-01-14 조회 2,506
16-01-14 조회 2,745
16-01-14 조회 2,554
16-01-13 조회 2,574
16-01-13 조회 2,588
16-01-13 조회 2,481
16-01-12 조회 2,671
16-01-11 조회 2,719
16-01-11 조회 2,658
16-01-11 조회 2,435
16-01-02 조회 2,887
15-12-31 조회 2,585
15-12-27 조회 2,683
15-12-27 조회 2,581
15-12-27 조회 2,639
15-12-26 조회 2,601
15-12-26 조회 2,675
15-12-26 조회 2,697
15-12-25 조회 3,469
15-12-25 조회 2,559
15-12-25 조회 2,568
15-12-25 조회 2,515
15-12-24 조회 3,065
15-12-23 조회 2,532
15-12-23 조회 2,661
15-12-23 조회 2,611
15-12-22 조회 2,656
15-12-22 조회 2,630
15-12-22 조회 2,537
15-12-21 조회 2,563
15-12-21 조회 2,588
15-12-21 조회 2,568
15-12-20 조회 2,619
15-12-20 조회 2,786
15-12-20 조회 2,552
15-12-19 조회 2,636
15-12-19 조회 2,625
15-12-19 조회 2,639
15-12-18 조회 2,985
15-12-18 조회 2,605
15-12-18 조회 2,595
15-12-18 조회 2,574
15-12-17 조회 2,561
15-12-17 조회 2,585
15-12-17 조회 2,546
15-12-16 조회 2,554
15-12-16 조회 2,591
15-12-16 조회 2,532
15-12-15 조회 2,543
15-12-15 조회 2,542
15-12-15 조회 2,535
15-12-14 조회 2,596
15-12-14 조회 2,687
15-12-14 조회 2,511
15-12-13 조회 2,476