HTML 2일차 이벤트 처리

/* 영문자나 숫자만 입력하기 */
<%@ page language="java" contentType="text/html; charset=EUC-KR"
    pageEncoding="EUC-KR"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>

<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<script LANGUAGE="JavaScript">
<!--
function validate(field)
{
var valid = "abcdefghijklmnopqrstuvwxyz0123456789"
var ok = "yes";
var temp;
for ( var i = 0; i < field.value.length; i++)
{
temp = "" + field.value.substring(i, i + 1);
if (valid.indexOf(temp) == "-1")
ok = "no";
}
if (ok == "no")
{
alert("영문자와 숫자만 입력할 수 있습니다");
field.value = ""
field.focus();
}
}
//-->
</script>
<title>JSP Test</title>

</head>
<body>

<form>
아이디<input type=text name="entry" onBlur="validate(this)"><input type=submit>
</form>

</body>
</html>


result)



댓글 없음: