YesYo.com MintState Forums
뒤로    YesYo.com MintState BBS > Tech > Javascript
검색
멤버이름    오토
비밀번호 
 

입력폼의 글자수 제한

페이지 정보

작성자 MintState 댓글 0건 조회 11,747회 작성일 08-11-17 11:49

본문

입력폼의 글자수 제한

<script>
function cb_check_text(o, name, length)
{
	if(o.value=="")
	{
		alert(name+" 입력해주십시오");
		o.focus();
		return false;
	}

	if(length>0)
	{
		if(o.length>length) 
		{
			alert(name+" "+length+"자 아내로 입력해주십시오.");
			o.focus();
			return false;
		}
	}

	return true;
}

function length_check(io, co, max, nam) {
	if(io.value.length > max) {
		alert(nam + "의 길이는 "+max+"자 이내로 해주십시오");
		io.value = io.value.substr(0, max);
	}
	co.value = io.value.length;
}

function check_form(f) {
	if(!cb_check_text(f.title, "홈페이지 제목을", 20)) return false;
	if(!cb_check_text(f.desc, "홈페이지 설명을", 50)) return false;
	if(!cb_check_text(f.username, "등록자 이름을", 10)) return false;

	return true;
}
</script>
<form name="add" method="post" action="index.html" onsubmit="return check_form(this)">
제목 : <input tabindex=1 type=text name='title' maxlength=20 style='width:310px' onKeyUp="length_check(this.form.title,this.form.count_title,20,'제목')" value="fdsfdasfadsdfsfdsafddsfdasfdsa"> 
현재 [<input type="text" name="count_title" style="border:0;background-color:#F5F3EF; color=#008000" readonly size=2 value=0>]자를 입력하셨습니다. <br /><br />
설명 : <textarea tabindex=2 cols=40 rows=6 name='desc' style='width:310px' onKeyUp="length_check(this.form.desc,this.form.count_desc,50,'설명')"></textarea>
현재 [<input type="text" name="count_desc" style="border:0;background-color:#F5F3EF;color=#008000;" readonly size=2 value=0>]자를 입력하셨습니다.<br /><br />
이름 : <input tabindex=3 type=text name='username' maxlength=10 style='width:310px'><br />
<br />
<input type="image" src=btn.gif>
</form>

댓글목록

등록된 댓글이 없습니다.

Total 178건 5 페이지
Javascript 목록
번호 제목 글쓴이 조회 날짜
98 MintState 12485 11-10
97 MintState 12367 11-17
96 MintState 12365 11-10
95 MintState 12328 11-17
94 MintState 12328 11-17
93 MintState 12311 11-17
92 MintState 12265 11-07
91 MintState 12264 10-31
90 MintState 12254 11-07
89 MintState 12252 11-17
88 MintState 12249 11-17
87 MintState 12175 10-29
86 MintState 12168 10-29
85 MintState 12136 11-17
84 MintState 12135 11-10
83 MintState 12109 11-07
82 MintState 12099 11-17
81 MintState 12096 10-29
80 MintState 12076 11-10
79 MintState 11938 11-10
게시물 검색
모바일 버전으로 보기
CopyRight ©2004 - 2024, YesYo.com MintState. ™