hoony's web study

728x90
반응형

<form name='form'>
<textarea name="content" cols="20" rows="7" style="overflow:auto;border:0px;width:160px;font-size:9pt;background-color:E5F1FB;" onKeydown="javascript:getLength(content.value)" onKeyUp="javascript:getLength(content.value)"></textarea>
<input type="text" size="3" style="border:0px;background-color:DBEBF8;text-align:right;width:91px;height:20px;color:blue;" NAME="txtlen" value="0" readonly><input type="text" size="10" value="/ 80 Byte" style="border:0px;background-color:DBEBF8;height:20px;color:666666;">
</form>

<script language="javascript">
function getLength(str)
{
 var max_byte = str.length+(escape(str)+"%u").match(/%u/g).length-1;
 var str_len = document.form.content.value.length;
 
 if (max_byte >= 80)
 {
  alert("한글 2글자, 영문 1글자가 80Byte를 넘을수 없습니다.\r\n더이살 쓸수 없습니다.")
  document.form.content.value = document.form.content.value.substring(0, str_len-1);
  document.form.txtlen.value = max_byte;
  return;
 }
 else
 {
  document.form.txtlen.value = max_byte;
 }

}
</script>

728x90

공유하기

facebook twitter kakaoTalk kakaostory naver band
loading