웹마스터 팁
page_full_width" class="col-xs-12" |cond="$__Context->page_full_width">
textarea 입력받는 글자수 제한하는 스크립트
2002.01.17 19:53
<!-- TWO STEPS TO INSTALL LIMIT TEXTAREA:
<!-- textarea의 입력 제한 설치 2단계 -->
1. Copy the coding into the HEAD of your HTML document
<!-- //1. html의 head에 소스를 넣어준다. -->
2. Add the last code into the BODY of your HTML document -->
<!-- //2. html의 body에 소스를 넣어준다. -->
<!-- STEP ONE: Paste this code into the HEAD of your HTML document -->
<!-- //1단계 : html의 head에 아래의 소스를 넣어라. -->
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!-- Original: Ronnie T. Moore -->
<!-- Web Site: The JavaScript Source -->
<!-- //원작자와 사이트명 -->
<!-- Dynamic 'fix' by: Nannette Thacker -->
<!-- Web Site: http://www.shiningstar.net -->
<!-- //수정한사람과 사이트명 -->
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- //이곳에 더많은 좋은 정보가 있다. -->
<!-- Begin
function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else
countfield.value = maxlimit - field.value.length;
}
End -->
<!-- // textcounter 함수의 시작과 끝, 위의 부분을 head에 넣어줌 -->
</script>
</HEAD>
<!-- STEP TWO: Copy this code into the BODY of your HTML document -->
<!-- //2단계 : html의 body에 아래의 코드를 넣어라. -->
<BODY>
<!-- textCounter() parameters are: text field, the count field, max length -->
<!-- //textcounter()에 사용되는 것들 : 텍스트필드, 카운트필드, 최대입력수 -->
<!-- //여기서부터는 위의 스크립트를 사용한 예제임(125자로 제한). 알맞게 수정하면 됨.... -->
<center>
<form name=myform action="YOUR-SCRIPT.CGI">
<font size="1" face="arial, helvetica, sans-serif"> ( You may enter up to 125 characters. )<br>
<textarea name=message wrap=physical cols=28 rows=4 onKeyDown="textCounter(this.form.message,this.form.remLen,125);" onKeyUp="textCounter(this.form.message,this.form.remLen,125);"></textarea>
<br>
<input readonly type=text name=remLen size=3 maxlength=3 value="125"> characters left</font>
<!-- 몇자남았는지카운트해주는부분 -->
</form>
</center>
<p><center>
<font face="arial, helvetica" SIZE="-2">Free JavaScripts provided<br>
by <a href="http://javascriptsource.com">The JavaScript Source</a></font>
</center><p>
<!-- Script Size: 1.37 KB -->
쉽게 말해서 head에 이걸 넣어줍니다.
<SCRIPT LANGUAGE="JavaScript">
function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else
countfield.value = maxlimit - field.value.length;
}
</script>
body에는 위의 예처럼 사용합니다. (맞게 수정하시면 됩니다.)
<form name=myform action="YOUR-SCRIPT.CGI">
<font size="1" face="arial, helvetica, sans-serif"> ( You may enter up to 125 characters. )<br>
<textarea name=message wrap=physical cols=28 rows=4 onKeyDown="textCounter(this.form.message,this.form.remLen,125);" onKeyUp="textCounter(this.form.message,this.form.remLen,125);"></textarea>
<br>
<input readonly type=text name=remLen size=3 maxlength=3 value="125"> characters left</font>
</form>
<!-- textarea의 입력 제한 설치 2단계 -->
1. Copy the coding into the HEAD of your HTML document
<!-- //1. html의 head에 소스를 넣어준다. -->
2. Add the last code into the BODY of your HTML document -->
<!-- //2. html의 body에 소스를 넣어준다. -->
<!-- STEP ONE: Paste this code into the HEAD of your HTML document -->
<!-- //1단계 : html의 head에 아래의 소스를 넣어라. -->
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!-- Original: Ronnie T. Moore -->
<!-- Web Site: The JavaScript Source -->
<!-- //원작자와 사이트명 -->
<!-- Dynamic 'fix' by: Nannette Thacker -->
<!-- Web Site: http://www.shiningstar.net -->
<!-- //수정한사람과 사이트명 -->
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- //이곳에 더많은 좋은 정보가 있다. -->
<!-- Begin
function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else
countfield.value = maxlimit - field.value.length;
}
End -->
<!-- // textcounter 함수의 시작과 끝, 위의 부분을 head에 넣어줌 -->
</script>
</HEAD>
<!-- STEP TWO: Copy this code into the BODY of your HTML document -->
<!-- //2단계 : html의 body에 아래의 코드를 넣어라. -->
<BODY>
<!-- textCounter() parameters are: text field, the count field, max length -->
<!-- //textcounter()에 사용되는 것들 : 텍스트필드, 카운트필드, 최대입력수 -->
<!-- //여기서부터는 위의 스크립트를 사용한 예제임(125자로 제한). 알맞게 수정하면 됨.... -->
<center>
<form name=myform action="YOUR-SCRIPT.CGI">
<font size="1" face="arial, helvetica, sans-serif"> ( You may enter up to 125 characters. )<br>
<textarea name=message wrap=physical cols=28 rows=4 onKeyDown="textCounter(this.form.message,this.form.remLen,125);" onKeyUp="textCounter(this.form.message,this.form.remLen,125);"></textarea>
<br>
<input readonly type=text name=remLen size=3 maxlength=3 value="125"> characters left</font>
<!-- 몇자남았는지카운트해주는부분 -->
</form>
</center>
<p><center>
<font face="arial, helvetica" SIZE="-2">Free JavaScripts provided<br>
by <a href="http://javascriptsource.com">The JavaScript Source</a></font>
</center><p>
<!-- Script Size: 1.37 KB -->
쉽게 말해서 head에 이걸 넣어줍니다.
<SCRIPT LANGUAGE="JavaScript">
function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else
countfield.value = maxlimit - field.value.length;
}
</script>
body에는 위의 예처럼 사용합니다. (맞게 수정하시면 됩니다.)
<form name=myform action="YOUR-SCRIPT.CGI">
<font size="1" face="arial, helvetica, sans-serif"> ( You may enter up to 125 characters. )<br>
<textarea name=message wrap=physical cols=28 rows=4 onKeyDown="textCounter(this.form.message,this.form.remLen,125);" onKeyUp="textCounter(this.form.message,this.form.remLen,125);"></textarea>
<br>
<input readonly type=text name=remLen size=3 maxlength=3 value="125"> characters left</font>
</form>
댓글 5
-
박신용
2002.01.20 04:23
ㅡ,.ㅡ 영어무지 잘하시네여..초보를 위해 올리셨다면 설명은 좀 한글로 쓰시던가 초보들 보기엔 다 프로그램인지 알것네....헉시 한글 몰르심 멀라두.. -
오기
2002.01.20 13:41
http://javascript.internet.com/forms/limit-textarea.html
이 소스를 가져온 페이지 입니다.
<!-- -->는 주석이고 이 부분을 제외하면 실제 소스는 얼마 되지 않습니다.
나머지 소스도 태그만 아시면 이해가 어렵지 않구요...
영어 못하지만 여기에 달린 영어로된 주석이 어렵다고는 생각 안합니다. ㅡ.ㅡ -
WOWpc
2002.01.28 04:04
한글도 1 문자로 인식하는데 문제가 있군요.
한글은 2 byte 로 처리해야 하는데 말이죠..
외국애들이 만든거라 어쩔 수 없나봅니다. -
김의주
2002.01.30 11:01
오... 이런건 그냥 문자(SMS)보내는 거에서 따서오면 되요 --; -
김동빈
2003.01.12 23:32
한글은 제한 안됩니다...
제목 | 글쓴이 | 날짜 |
---|---|---|
PHP 혼자 공부하기 - 10 :: 정규식 패턴 문법 [3] | 행복한고니 | 2003.04.15 |
PHP 혼자 공부하기 - 9 :: 정규식 함수 [3] | 행복한고니 | 2003.04.14 |
[동주아빠] PHP 게시판(21강) - 목록 보기(4) list.php 설명(中) | 손병목 | 2002.12.30 |
폼메일 --- 제로님 예전 폼메일 수정 변경.. [11] | uropa™ | 2002.12.27 |
Java Applet을 활용한 업로드시 전송률 확인하기.. | 아이쿠 | 2002.10.19 |
꼭 알아야 하는 4가지 쿼리문 | Mr. JH | 2002.08.22 |
누구나 만들수있는 게시판 [글목록 list.php 부분] [6] | Mr. JH | 2002.08.21 |
원격침입과 도스공격이 가능한 PHP 취약점 [11] | JunYa™ | 2002.07.24 |
php 와 flash 의 연동을 이용한 제로보드 최근글 추출...(소스) | 주현석 | 2002.06.05 |
[OsE=] 오스보드에 적용된 페이징 방법(알고리즘?) | OsE= | 2002.03.02 |
최근게시물 - 첫글은 내용까지, 다음글부터 목록만... [15] | СreдturЭ | 2001.04.16 |
공부용 방명록이에욥^^. 주석왕창(페이지분할등.기능있어욥~) [2] | 프리^^ | 2001.04.16 |
최근 게시물을 나타내는 원리와 방법 [55] | zero | 2000.03.06 |
교육용 메모장 #4 [18] | zero | 2000.07.10 |
카운터를 만들어봅시다~ (수정본) [181] | zero | 2000.03.08 |
MYSQL Query의 간단한 사용법 [82] | zero | 2000.03.06 |
새로운 뉴스티커 [1] | 아렌티 | 2006.04.25 |
문자열 길이(byte)에 따라 자르기... | 행복한고니 | 2002.10.11 |
textarea 입력받는 글자수 제한하는 스크립트 [5] | 오기 | 2002.01.17 |
자동 스크롤 메뉴 (끄기 기능, 무한 스크롤 X) [6] | ☺심심 | 2004.05.02 |