본문 바로가기

Programming/JavaScript

한글입력 금지

<HTML>
<HEAD>
<TITLE>Script </TITLE>

<script LANGUAGE="JavaScript">
<!--
function hanCheck(x) {
for(i=0;i<x.user_id.value.length;i++) {
var a=x.user_id.value.charCodeAt(i);
if (a > 128) {
alert('한글 입력 금지');
x.user_id.value="";
x.user_id.focus();
return;
}
}
alert("ok");
}
//-->
</script>

</HEAD>

<BODY>

>
User_id <input type=text name="user_id">
<input type=button ="hanCheck(this.form)" value="Check">
</

</BODY>
</HTML>