본문 바로가기
JAVASCRIPT/한글만 입력하게 하는 text박스

한글만 입력하도록 하는 text 박스

by 정윤재 2008. 11. 6.

<html>
<head>
<title>   </title>
<script language="javascript">
<!--
function check()
{
 var form = document.form1;
 var box = form.bx1;
 var str = box.value;
 for(i=0; i<str.length; i++)
 {
  if(!((str.charCodeAt(i) > 0x3130 && str.charCodeAt(i) < 0x318F) || (str.charCodeAt(i) >= 0xAC00 && str.charCodeAt(i) <= 0xD7A3)))
  {
   alert("반드시 한글만 입력하세요");
   box.value = "";
   return false;
  }
  else; // 처리
 }
}
//-->
</script>
</head>

<body>
<form name="form1" method="post" action="#" onsubmit="return check() ">
한글 : <input type="text" name="bx1" size="" maxlength="" />
<input type="submit">
</form>

</body>
</html>



댓글