Æ÷Ä¿½º¸¦ ÁÖ°í, ÀÚÆÇÀ» ´­·¶´Ù ¶¼¾î º¸¶ó

Æ÷Ä¿½º¸¦ ÁÖ°í ÀÚÆÇÀ» ´©¸¥ »óÅ µ¿¾È KeyDown() ±â´ÉÇÔ¼ö¸¦ È£ÃâÇÏ°í, ´©¸¥ °ÍÀ» ÇØÁ¦Çϸé KeyUp() ±â´ÉÇÔ¼ö¸¦ È£ÃâÇÑ´Ù.

<SCRIPT>
function KeyDown(obj){
  obj.style.backgroundColor='#ffff00';
}
function KeyUp(obj){
  obj.style.backgroundColor='#00ffff';
}
</SCRIPT>

<DIV onKeyDown="KeyDown(this)" onKeyUp="KeyUp(this)"
  style="width:300;border:solid 1 blue;padding:4px">Æ÷Ä¿½º¸¦ ÁÖ°í, ÀÚÆÇÀ» ´­·¶´Ù ¶¼¾î º¸¶ó</DIV>
Æ÷Ä¿½º¸¦ ÁÖ°í, ÀÚÆÇÀ» ´­·¶´Ù ¶¼¾î º¸¶ó

onkeypress À̺¥Æ®ÀÇ °æ¿ì ¾ó¸¶³ª ¿À·¡µ¿¾È ÀÚÆÇÀ» ´©¸£°í ¶¼¾ú´ÂÁö´Â °ü°è¾øÀÌ ÇѹøÀÌ¶óµµ ÀÚÆÇÀ» ´­·¶¾ú´ÂÁö¸¦ °ËÁ¤ÇÏ°Ô µÈ´Ù.
¿¹Á¦¿¡¼­´Â ÇѹøÀÇ À̺¥Æ®·Î ¹è°æ»ö º¯°æ°ú °æ°í, µÎ°¡Áö ÀÛ¿ëÀ» ÇÏ°Ô Javascript¿¡¼­ ÄÚµùÇÏ¿´´Ù.

<DIV onKeyPress="this.style.backgroundColor='#ffff00';alert('Å°°¡ ´­·È¾ú½À´Ï´Ù.')"
  style="width:300;border:solid 1 blue;padding:4px">Æ÷Ä¿½º¸¦ ÁÖ°í, ÀÚÆÇÀ» ´­·¶´Ù ¶¼¾î º¸¶ó</DIV>
³ë¶õ ¹Ú½º¿¡ ÃÊÁ¡À» ÁÖ¼¼¿ä.

¹Ú½º¿¡ ÃÊÁ¡À» ÁÖ°í Å°ÀÔ·Â ÇØ º¸¶ó
<SCRIPT>
var charCode;
function checkchar(charCode){  // ÀÔ·ÂµÈ Å° ÄÚµå(10Áø¼ö)·Î ±â´ÉÇÔ¼ö¸¦ ¼öÇàÇÑ´Ù
  if ((charCode>47) && (charCode<58)) alert('('+charCode+')=¼öÄ¡')  // ¼öÄ¡ ¹üÀ§(0~9) Á¡°Ë
  else if ((charCode>64) && (charCode<91)) alert('('+charCode+')=´ë¹®ÀÚ')  // ´ë¹®ÀÚ ¹üÀ§(A~Z) Á¡°Ë
  else if ((charCode>96) && (charCode<123)) alert('('+charCode+')=¼Ò¹®ÀÚ')  // ¼Ò¹®ÀÚ ¹üÀ§(a~z) Á¡°Ë
  else alert('('+charCode+')=¼öÄ¡µµ ¾ËÆĺªµµ ¾Æ´Ô');
  // fname.iname.value=''; // ¸Å¹ø Àü¹ø ÀÔ·Â ¹®ÀÚ¸¦ Áö¿ì·Á¸é 
  fname.iname.focus(); // ÃÊÁ¡À» ´Ù½Ã ÁØ´Ù
}
</SCRIPT>

<DIV id="showF" style="border:solid 1 blue;text-align:center;color:red">³ë¶õ ¹Ú½º¿¡ ÃÊÁ¡À» ÁÖ¼¼¿ä.</DIV>
<FORM name=fname>
<INPUT name=iname
  onkeypress="checkchar(event.keyCode)"
  onFocus="showF.innerHTML='<FONT color=blue>ÃÊÁ¡ÀÌ ¿Ô¾î¿ä. ÀÔ·ÂÇØ º¸¶ó.</FONT>'"
  onBlur="showF.innerHTML='<FONT color=red>³ë¶õ ¹Ú½º¿¡ ÃÊÁ¡À» ÁÖ¼¼¿ä.</FONT>'"
  style="border:solid 1 red;text-align:center;padding:.5em;background:yellow">
<INPUT type=reset value='Reset'><BR>
¹Ú½º¿¡ ÃÊÁ¡À» ÁÖ°í Å°ÀÔ·Â ÇØ º¸¶ó<BR>
</FORM>