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

입력폼의 글자수 제한

페이지 정보

작성자 MintState 댓글 0건 조회 11,797회 작성일 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건 4 페이지
Javascript 목록
번호 제목 글쓴이 조회 날짜
118 MintState 10051 11-10
117 MintState 11445 11-10
116 MintState 14782 11-11
115 MintState 9949 11-17
114 MintState 11093 11-17
113 MintState 9858 11-17
112 MintState 10174 11-17
111 MintState 9393 11-17
110 MintState 10572 11-17
109 MintState 11814 11-17
108 MintState 13834 11-17
107 MintState 12838 11-17
106 MintState 14268 11-17
105 MintState 20177 11-17
104 MintState 13866 11-17
103 MintState 12315 11-17
102 MintState 14404 11-17
101 MintState 9636 11-17
열람중 MintState 11798 11-17
99 MintState 16154 11-17
게시물 검색
모바일 버전으로 보기
CopyRight ©2004 - 2024, YesYo.com MintState. ™