ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[±Ð¾Ç] (±Ð¾Ç²Ä22½g)ºô­¶»Pªí³æ ¤U½g

[±Ð¾Ç] (±Ð¾Ç²Ä22½g)ºô­¶»Pªí³æ ¤U½g

¦bºô­¶¤¤³]¸mªí³æªº¥Î·N¡A¤£¥~¥G¬O¦¬¶°ÂsÄýªÌ©Òµ¹¤©ªº¸ê°T¡AµM«á¹ï³o¨ÇÂsÄýªÌ©Òµ¹¤©ªº¸ê°T¥[¥H³B²z¡A¦Ó³B²z³o¨Ç¸ê°Tªº«áºÝµ{¦¡³q±`¬OCGI¡BASP¡A·íªí³æ¸ê®Æ°e¥æºô­¶ªº«áºÝµ{¦¡³B²z®É¡A­Y¦³ªí³æ¸ê®ÆªÅ¥Õ©Î¤º®e¿ù»~¡A±`±`·|¾É­P«áºÝµ{¦¡°õ¦æ¿ù»~¡A©Î³\§A·|»¡¡G¦b«áºÝµ{¦¡¤¤¥[¤JÀËÅç¸ê®Æ¥¿½T©Êªºµ{¦¡±Ô­z¨Ó§PÂ_¤£´N¦æ¤F¡I·íµM¡A³o¬O¤@­Ó¤èªk¡A¦ý§A¥²¶·©ú¥Õ¡A©Ò¿×ªº«áºÝµ{¦¡¬O¦b¦øªA¾¹(server)¤W°õ¦æ¡A¦pªG§Ú­Ìªººô¯¸«Ü¨üÅwªï¡A«hÀW¼e¬y¶q±N¬Û·í¤j¡A¥ú¬Oºô­¶ªºÅª¨ú´N¨Ï¦øªA¾¹(server)ªº­t¾á«D±`¤j¡A¦pªGÁÙ­n¦øªA¾¹ºÝ­t³dÀËÅçªí³æ¸ê®Æªº¥¿½T©Ê¡A¨º¦øªA¾¹ªº°õ¦æ®Ä²v´N§ó§C¤F¡I

¬°¤F´î¤Ö¦øªA¾¹¤£¥²­nªº®Ä¯à·l¥¢¡A§Ú­Ì¥i¥H§Q¥ÎJavaScriptµ{¦¡¦b«È¤áºÝ(client)¡A¤]´N¬OÂsÄýªÌªºÂsÄý¾¹¤¤¡A¶i¦æªí³æ¤º®e¥¿½T©ÊªºÅçÃÒ¡A¦Ó¤£»Ý­n±Nªí³æ¤º®e¥¿½T©ÊªºÅçÃÒ¤u§@¥æ¥Ñ¦øªAºÝ¨Ó³B²z¡AÁקK³y¦¨¦øªA¾¹ªº­t¾á¡C


onSubmit¨Æ¥ó
¦b§Ú­Ìªí³æ¸ê®Æ³Q¶Ç°e©Î°e¥æ¦øªA¾¹ºÝ¤§«e¡]get/post¡^¡A§Ú­Ì¥i¥H§Q¥Î¡yonSubmit¡z¨Æ¥ó³B²z¾¹¨Ó©I¥s§Ú­ÌÅçÃÒªí³æ¸ê®Æ¤º®eªºJavaScript¨ç¦¡¡C½Ðª`·N¡G¡yonSubmit¡z¨Æ¥ó³B²z¾¹¬O±Mªù¬°ªí³æ¸ê®Æ³Q¶Ç°e©Î°e¥æ¦øªA¾¹ºÝ¤§«eªº½T»{°Ê§@¦Ó³]­p¡I

¤U¦C¬Oªí³æºô­¶¤¤ªº³¡¤À±Ô­z¡A¸Ì­±¦³¤@­Óªí³æ¡A¸Óªí³æ§t¦³¤T­Ó³æ¦æ¤å¦r¤è¶ô¤¸¥ó¤Î¨â­Ó«ö¶s¤¸¥ó¡G
  1. <form name="myform" method="POST" action="«áºÝCGI³B²zµ{¦¡" onSubmit="return test(this)">
  2. <table border="0" width="500" height="220">
  3. <tr>
  4. <td width="457">©m¦W¡G<input type="text" name="name" size="24"></td>
  5. </tr>
  6. <tr>
  7. <td width="457">E-Mail¡G<input type="text" name="email" size="23"></td>
  8. </tr>
  9. <tr>
  10. <td width="457">¦í§}¡G<input type="text" name="address" size="56"></td>
  11. </tr>
  12. <tr>
  13. <td width="457">
  14. <input type="submit" value="°e¥X" name="B1">
  15. <input type="reset" value="­«¶ñ" name="B2">
  16. </td>
  17. </tr>
  18. </table>
  19. </form>
½Æ»s¥N½X
­ì©l½X(²Ä4¡B7¡B10¦æ)¬°³æ¦æ¤å¦r¤è¶ô¤¸¥ó¡F­ì©l½X(²Ä14¡B15¦æ)¬°«ö¶s¤¸¥ó¡A¡uname¡vÄݩʬҦ³³]©wËç¡C

½Ðª`·N¬Ý¨ì­ì©l½X(²Ä1¦æ)¡A§Ú­Ì¬O±NonSubmit¨Æ¥ó³B²z¾¹©ñ¦bªí³æ¼ÐÅÒ<FORM>¤§¤¤¡Aªí³æ¼ÐÅÒ<FORM>¬O°ß¤@¥i¥H©ñ¸monSubmit¨Æ¥ó³B²z¾¹ªº¦a¤è¡A¤£ºÞ¬O¥H¶Ç°e©Î°e¥æªº¤è¦¡(method=¡¨get/post¡¨)¥æ¥I¦øªA¾¹ªí³æ¸ê®Æ¡A·íÂsÄýªÌ«ö¤U¡usubmit¡]°e¥X¡^¡v«ö¶s®É¡A³£±N·|IJµoonSubmit¨Æ¥ó³B²z¾¹¨Ó©I¥s¡utest()¡vJavaScript¨ç¦¡¡A³o®É­Ô¡Aªí³æ¤ºªº¸ê®Æ±N·|¥ý°e¥æ¡utest()¡vJavaScript¨ç¦¡¡A¦pªG¡A¡utest()¡vJavaScript¨ç¦¡¦^­È¬°¡utrue¡v¡Aªí³æ¸ê®Æ¤~·|¶Ç°e©Î°e¥æµ¹«áºÝ³B²zµ{¦¡¡]action=¡¨«áºÝCGI³B²zµ{¦¡¡¨¡^¡F­Y¡utest()¡vJavaScript¨ç¦¡¦^­È¬°¡ufalse¡v«hªí³æ¸ê®Æªº¶Ç°e©Î°e¥æ¤u§@´N·|³Q²×¤î¡I
¦b©I¥s¡utest()¡vJavaScript¨ç¦¡®É¡A§Ú­Ì¨Ï¥Î¤F¤@­Ó¡uthis¡vÃöÁä¦r¡A·N«ä¬O»¡¡G±Nªí³æ¤ºªº¸ê®Æ¶Ç»¼µ¹¨ç¦¡°µ³B²z¡I

¤U¦C¬°¡utest()¡vJavaScript¨ç¦¡ªº¤º®e¡G
  1. <SCRIPT LANGUAGE="JavaScript">
  2. //ÅçÃÒªí³æÄæ¦ì¤º®e¬O§_¶ñ¼gªº¨ç¦¡
  3. function test(form)
  4. {
  5. //Àˬd©m¦WÄæ¦ì¬O§_¶ñ¼g      
  6. if(document.myform.name.value=="")
  7. {
  8. alert('½Ð¶ñ¼g©m¦W,ÁÂÁÂ!')
  9. document.myform.name.focus()
  10. return false
  11. }

  12. //Àˬd¹q¤l¶l¥ó¬O§_¶ñ¼g
  13. else if (document.myform.email.value=="")
  14. {
  15. alert('½Ð¶ñ¼gE-Mail,ÁÂÁÂ!')
  16. document.myform.email.focus()
  17. return false
  18. }

  19. //Àˬd¦a§}Äæ¦ì¬O§_¶ñ¼g
  20. else if (document.myform.address.value=="")
  21. {
  22. alert('½Ð¶ñ¼g¦í§},ÁÂÁÂ!')
  23. document.myform.address.focus()
  24. return false
  25. }

  26. //Äæ¦ì¸ê®Æ³£¦³¶ñ¼g«h¤¹³\¶Ç°eªí³æ¸ê®Æ
  27. return true
  28. }
  29. </SCRIPT>
½Æ»s¥N½X
ªí³æ¤ºªº¸ê®Æ°e¥æ¡utest()¡vJavaScript¨ç¦¡«á¡A±µµÛ¹ïªí³æ¤ºªº¸ê®Æ¶i¦æÅçÃÒ¡A¥HÅçÃÒ¡uname(©m¦W)¡v³æ¦æ¤å¦r¤è¶ô¬°¨Ò¡]²Ä6¦Ü11¦æÂŦâ­ì©l½X°Ï¬q¡^¡G§Q¥Îif§PÂ_±Ô­zÀËÅç¡uname(©m¦W)¡v³æ¦æ¤å¦r¤è¶ôªº¤º®e¬O§_¬°ªÅ¥Õ¡A¦pªG¬OªÅ¥Õ¡A«h§Q¥Îalert()¨ç¬O¿é¥X¤@¬q¿ù»~°T®§¡A¨Ã¥B¡A§Q¥Î¡yfocus¡z¤èªk±N¾Þ§@µJÂI²¾¦Ü¡uname(©m¦W)¡v³æ¦æ¤å¦r¤è¶ô¡A±µµÛ¡A¨ç¦¡¦^¶Ç¡ufalse¡v²×¤î±Nªí³æ¸ê®Æ¶Ç°e©Î°e¥æµ¹«áºÝ³B²zµ{¦¡ªº°Ê§@¡C

¦bÀËÅ秹¦U­Ó¤¸¥óÄæ¦ìªº¤º®e³£¤£¬OªÅ¥Õ«á¡A«h¨ç¦¡¦^¶Ç¡utrue¡v¡]²Ä30¦æ¬õ¦â­ì©l½X°Ï¬q¡^Ä~Äò±Nªí³æ¸ê®Æ¶Ç°e©Î°e¥æµ¹«áºÝ³B²zµ{¦¡ªº°Ê§@¡C
  1. <HTML>
  2. <HEAD>
  3. <TITLE>ªí³æÅçÃÒ</TITLE>
  4. </HEAD>
  5. <SCRIPT LANGUAGE="JavaScript">
  6. //ÅçÃÒªí³æÄæ¦ì¤º®e¬O§_¶ñ¼gªº¨ç¦¡
  7. function test(form)
  8. {
  9. //Àˬd©m¦WÄæ¦ì¬O§_¶ñ¼g      
  10. if(document.myform.name.value=="")
  11. {
  12. alert("½Ð¶ñ¼g©m¦W,ÁÂÁÂ!")
  13. document.myform.name.focus()
  14. return false
  15. }

  16. //Àˬd¹q¤l¶l¥ó¬O§_¶ñ¼g
  17. else if (document.myform.email.value=="")
  18. {
  19. alert("½Ð¶ñ¼gE-Mail,ÁÂÁÂ!")
  20. document.myform.email.focus()
  21. return false
  22. }

  23. //Àˬd¦a§}Äæ¦ì¬O§_¶ñ¼g
  24. else if (document.myform.address.value=="")
  25. {
  26. alert("½Ð¶ñ¼g¦í§},ÁÂÁÂ!")
  27. document.myform.address.focus()
  28. return false
  29. }

  30. //Äæ¦ì¸ê®Æ³£¦³¶ñ¼g«h¤¹³\¶Ç°eªí³æ¸ê®Æ
  31. return true
  32. }
  33. </SCRIPT>

  34. <BODY bgcolor="#3399FF">
  35. <table border="1" width="600" bordercolorlight="#000080" bordercolor="#00FFFF" cellspacing="0">
  36. <tr>
  37. <td width="100%" bordercolorlight="#000000">
  38. <form name="myform" method="POST" action="«áºÝCGI³B²zµ{¦¡" onSubmit="return test(this)">
  39. <div align="center">
  40. <center>
  41. <table border="0" width="500" height="220" cellspacing="0" cellpadding="0" bgcolor="#004EC3">
  42. <tr>
  43. <td width="457"><font color="#FFFFFF">©m¦W¡G
  44. <input type="text" name="name" size="24"></font></td>
  45. </tr>
  46. <tr>
  47. <td width="457"><font color="#FFFFFF">E-Mail¡G
  48. <input type="text" name="email" size="23"></font></td>
  49. </tr>
  50. <tr>
  51. <td width="457"><font color="#FFFFFF">¦í§}¡G
  52. <input type="text" name="address" size="56"></font></td>
  53. </tr>
  54. <tr>
  55. <td width="457">
  56. <input type="submit" value="°e¥X" name="B1">
  57. <input type="reset" value="­«¶ñ" name="B2"></td>
  58. </tr>
  59. </table>
  60. </center>
  61. </div>
  62. </form>
  63. </td>
  64. </tr>
  65. </table>
  66. </BODY>
  67. </HTML>
½Æ»s¥N½X
¤ß¦w¡A¥­¦w   
µoªí¥ô¦óµL·N¸qªº·PÁ©ÎÄé¤ô¤å³¹¤@«ß¬å,¬Ã±¤±b¸¹,½Ð¸Ô¾\ª©³W!!

¥ì©f¨àÅçÃÒ
¥ì©f¨à¡]E-Mail¡^¬O¥Ø«eºô¸ô±Ú³Ì¨Îªº®ø®§¶Ç»¼¤u¨ã¡AE-Mailªº¦n³B´N¬O¸gÀÙ§Ö³t¡A¦ý¬OE-Mail³o­Ó¹q¤l¶l¥ó«H½c¦a§}¡A´N¦p¦P§Ú­Ìªº¶l¥ó¦¬¥ó¦a§}¤@¯ë¡A¸U¤@¦¬¥ó¤H¦a§}¼g¿ù¤F¡A«H¤]´N¿ù°e¨ì¥L¤Hªº¤â¸Ì¡A¬Û¹ïªº¡A§Aµ¹¿ù¤F¦a§}¡A¤H®a¨Ì§Aµ¹ªº¦a§}¦^«H¡Aµ²ªG¤£¬O¡u¬dµL¦¹¤H¡v¡G«H¥ó³Q°h¦^¡A´N¬O³Q§O¤H¦¬¨«¤F¡I

¹q¤l¶l¥ó«H½cªº®æ¦¡¤¤¡A¤@©w·|§t¦³¤@°¦¤p¦Ñ¹«¡u@¡v¡A¦Ó¥B³Ì¤ÖÁÙ·|¦³¤@­ÓÂI¡u.¡]dot¡^¡v¡A¨Ò¦p¡A¤p»xªº¥ì©f¨à¡G[email protected]¡A®Ú¾Ú³o¨â­Ó­n¶µ§Ú­Ì¦Ü¤ÖÁÙ¥i¥HÀËÅç¥ì©f¨àªº®æ¦¡¬O§_¥¿½T¡C

¦b¤W¤@¸`¤¤§Ú­Ì¥u¬OÀËÅçE-MailÄæ¦ì¤º¬O§_¦³¸ê®Æ¦s¦b¡A§Y¨Ï¸ÓÄæ¦ì¤¤ÂsÄýªÌ¦³¿é¤J¸ê®Æ¡A¦ý³o¨Ã¤£ªí©Ò¿é¤Jªº¸ê®Æ´N¬O¤@­Ó¹q¤l¶l¥ó«H½c¦a§}¡A©Ò¥H§Ú­Ì¥i¥H±Ä¥Î¦p¤Uªº¨ç¦¡¨Ó¶i¦æE-MailÄæ¦ìªº¸ê®ÆÅçÃÒ§PÂ_¡G
  1. function testEmail(yourmail)
  2. {
  3. if (yourmail.value.indexOf("@") == "-1" ||
  4.     yourmail.value.indexOf(".") == "-1" ||
  5.     yourmail.value == "")
  6. {
  7. return false
  8. }
  9. return true
  10. }
½Æ»s¥N½X
§Ú­Ì¨Ï¥Î³o­ÓtestEmail¨ç¦¡¨ÓÅçÃÒE-Mail¹q¤l¶l¥ó«H½c¦a§}¬O§_¥¿½T®É¡A·íµM±o¥ý¶Ç»¼¤@­ÓE-Mail¹q¤l¶l¥ó«H½c¦a§}°Ñ¼Æµ¹¨ç¦¡ªºÅܼơuyourmail¡v¡AµM«á¦A¨ÓÀËÅçÅܼƬO§_§t¦³¤p¦Ñ¹«¡u@¡v»PÂI¡u.¡]dot¡^¡v¡C

·ítestEmail¨ç¦¡¦Ûªí³æ¤¤±µ¦¬¨ì¤F¤@­ÓE-Mail¹q¤l¶l¥ó«H½c¦a§}ÅܼơA¦pªGÅܼƤº®e¤£¬O¨S¦³¥ô¦ó¸ê®Æ¡A¦Ó¥B§t¦³¤p¦Ñ¹«¡u@¡v»PÂI¡u.¡]dot¡^¡v®É¡AtestEmail¨ç¦¡·|¦^¶Ç¤@­Ó¡utrue¡v­È¡A§_«h¡AtestEmail¨ç¦¡«h·|¦^¶Ç¤@­Ó¡ufalse¡v­È¡C

insexOf()¤èªk¡G
indexOf()¤èªk¬O¥Î¨Ó¡u·j´M¡v¦r¤¸¦ì¸m¡A°²³]§Ú­ÌªºÅܼƤº¦³¤@­ÓE-mail¹q¤l«H½c¦a§}¡G
  1. yourmail=¡¨[email protected]¡¨
½Æ»s¥N½X
­Y§Ú­Ì­n´M§ä¤p¦Ñ¹«¡u@¡v¡A´N¥i¥H§Q¥ÎindexOf()¤èªk¡G
  1. Mouse=yourmail.indexOf(¡§@¡¨)
½Æ»s¥N½X
½Ð°Ý§A¡GÅܼÆMouse¤ºªº¸ê®Æ¬O¤°»ò¡H¬O¡u@¡v¡A¿ù¡I¡I¬O¡u7¡v°Õ¡IindexOf()¤èªk¨ú¦^ªº¬O¤p¦Ñ¹«¡u@¡v¦b¡u[email protected]¡v³o­Ó¦r¦ê¸Ìªº¦r¤¸¦ì¸m¡A¯S§Oª`·N¡G¦r¤¸¦ì¸mªº­pºâ¶¶§Ç¬O±q¡u0¡v¶}©l¡A©Ò¥H¡A¤p¦Ñ¹«¡u@¡v¦b¦r¦ê¸Ìªº¦r¤¸¦ì¸m¬O¡u7¡v¡A¨º¦pªG§ä¤£¨ì¤p¦Ñ¹«¡u@¡v©O¡H¨º»òindexOf()¤èªkªº¶Ç¦^­È´N¬O¡u-1¡v¡A¤]´N¬O»¡¡G¥u­nindexOf()¤èªk¦r¦r¦ê¤¤§ä¤£¨ì§A©Ò«ü©wªº¦r¡A«hindexOf()¤èªkªº¶Ç¦^­È´N¬O¡u-1¡v¡C³o¤]´N§Ú­Ì¦btestEmail¨ç¦¡¤¤¡A¬°¦ó­n¤ñ¸ûindexOf()¤èªkªº¶Ç¦^­È¬O¤£¬O¡u-1¡vªº­ì¦]¤F¡I


¹ê§@¾Ç²ß¡G
ÅçÃÒE-Mail¹q¤l¶l¥ó«H½c¦a§}¬O§_¥¿½T¡C
  1. <HTML>
  2. <HEAD>
  3. <TITLE>E-MailÅçÃÒ</TITLE>
  4. </HEAD>
  5. <SCRIPT LANGUAGE="JavaScript">
  6. //ÅçÃÒE-MailÄæ¦ì¤º®eªº¨ç¦¡
  7. function test(form)
  8. {
  9. //Àˬd¹q¤l¶l¥ó¬O§_§t¦³¤p¦Ñ¹«      
  10. if(document.myform.email.value.indexOf("@")=="-1")
  11. {
  12. alert("Email¯Ê¤Ö¤p¦Ñ¹«@")
  13. document.myform.email.focus()
  14. return false
  15. }

  16. //Àˬd¹q¤l¶l¥ó¬O§_§t¦³ÂI
  17. else if (document.myform.email.value.indexOf(".")=="-1")
  18. {
  19. alert("Email®æ¦¡¿ù»~!")
  20. document.myform.email.focus()
  21. return false
  22. }

  23. //Àˬd¹q¤l¶l¥ó¬O§_¶ñ¼g
  24. else if (document.myform.email.value=="")
  25. {
  26. alert("¨S¦³¶ñ¼gEmail!")
  27. document.myform.email.focus()
  28. return false
  29. }

  30. return true
  31. }
  32. </SCRIPT>

  33. <BODY bgcolor="#3399FF">
  34. <form name="myform" method="POST" action="«áºÝCGI³B²zµ{¦¡" onSubmit="return test(this)">
  35. <div align="center">
  36. <center>
  37. <table border="0" cellspacing="0" cellpadding="0" bgcolor="#004EC3">
  38. <tr>
  39. <td width="457" height="70"><font color="#FFFFFF">E-Mail¡G
  40. <input type="text" name="email" size="23"></font></td>
  41. </tr>
  42. <tr>
  43. <td width="457" height="24">
  44. <input type="submit" value="ÅçÃÒ" name="B1">
  45. <input type="reset" value="­«¶ñ" name="B2"></td>
  46. </tr>
  47. </table>
  48. </center>
  49. </div>
  50. </form>
  51. </BODY>
  52. </HTML>
½Æ»s¥N½X
¤ß¦w¡A¥­¦w   
µoªí¥ô¦óµL·N¸qªº·PÁ©ÎÄé¤ô¤å³¹¤@«ß¬å,¬Ã±¤±b¸¹,½Ð¸Ô¾\ª©³W!!

TOP

        ÀR«ä¦Û¦b : ¡i¬O§_µo´§¤F¨}¯à¡H¡j¤H¶¡¹Ø©R¦]¬°µu¼È¡A¤~§óÅã±o¬Ã¶Q¡CÃø±o¨Ó¤@½ë¤H¶¡¡AÀ³°Ý¬O§_¬°¤H¶¡µo´§¤F¦Û¤vªº¨}¯à¡A¦Ó¤£­n¤@¨ý¨Dªø¹Ø¡C
ªð¦^¦Cªí ¤W¤@¥DÃD