01.
<html>
02.
<head>
03.
<meta http-equiv=
"Content-Type"
content=
"text/html; charset=windows-874"
/>
04.
<title> test </title>
05.
<script language=
"javascript"
>
06.
function
Chk(intLength)
07.
{
08.
if
(parseInt(intLength) != 2)
09.
{
10.
alert(
"กรอกข้อมูลให้ครบ 2 ตัวอักษร"
);
11.
document.frm.text1.focus();
12.
}
else
{
13.
alert(
"สำเร็จ"
);
14.
}
15.
}
16.
</script>
17.
</head>
18.
<body>
19.
<form name=
"frm"
id=
"frm"
method=
"post"
action=
""
>
20.
Input : <input type=
"text"
name=
"text1"
maxlength=
"2"
>
21.
<input type=
"button"
value=
"save"
onclick=
"Chk(text1.value.length);"
>
22.
</form>
23.
</body>
24.
</html>