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

입력폼의 글자수 제한

페이지 정보

작성자 MintState 댓글 0건 조회 11,744회 작성일 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 10722 11-17
97 MintState 14032 11-17
96 MintState 12498 11-17
95 MintState 12327 11-17
94 MintState 14074 11-17
93 MintState 11590 11-17
92 MintState 18091 11-17
91 MintState 9232 11-17
90 MintState 10104 11-17
89 MintState 11359 11-17
88 MintState 11931 11-17
87 MintState 11457 11-17
86 MintState 12096 11-17
85 MintState 13079 11-17
84 MintState 11100 11-17
83 MintState 12365 11-17
82 MintState 11249 11-17
81 MintState 12775 11-17
80 MintState 16091 11-17
열람중 MintState 11745 11-17
게시물 검색
모바일 버전으로 보기
CopyRight ©2004 - 2024, YesYo.com MintState. ™