职业IT人-IT人生活圈

 找回密码
 成为会员
搜索
查看: 1635|回复: 0

小玩意javascript的图片验证

[复制链接]
蓝色梦幻 发表于 2007-4-17 19:15 | 显示全部楼层 |阅读模式
这个试验,本来是做的是输入达不到一定要求,用图片实现内容提示,现在初步完成,这是NET2003的html层代码,无后台代码
<%@ Page language=\"c#\" Codebehind=\"WebForm1.aspx.cs\" AutoEventWireup=\"false\" Inherits=\"WebApplication2.WebForm1\" %>
<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\" >
<HTML>
  <HEAD>
    <title>WebForm1</title>
    <meta content=\"Microsoft Visual Studio .NET 7.1\" name=\"GENERATOR\">
    <meta content=\"C#\" name=\"CODE_LANGUAGE\">
    <meta content=\"JavaScript\" name=\"vs_defaultClientScript\">
    <meta content=\"http://schemas.microsoft.com/intellisense/ie5\" name=\"vs_targetSchema\">
    <script language=\"javascript\" id=\"clientEventHandlersJS\">
<!--
function T1_onkeyup() {
  if(document.card.T1.value.length<4)
  {
     img1.style.display=\"block\"
  }
  else
  {
     img1.style.display=\"none\"
  }
  if(document.card.T1.value.length==4){
     document.card.T2.focus();
   }
}
function T2_onkeyup() {
if(document.card.T2.value.length<4)
  {
     img2.style.display=\"block\"
  }
  else
  {
     img2.style.display=\"none\"
  }
  if(document.card.T2.value.length==4){
     document.card.T3.focus();
   }
}

function T3_onkeyup() {
if(document.card.T3.value.length<4)
  {
     img3.style.display=\"block\"
  }
  else
  {
     img3.style.display=\"none\"
  }
  if(document.card.T3.value.length==4){
     document.card.T4.focus();
   }
}
function T4_onkeyup() {
if(document.card.T4.value.length<4)
  {
     img4.style.display=\"block\"
  }
  else
  {
     img4.style.display=\"none\"
  }

}

//-->
    </script>
    <script language=\"vbscript\">
sub cha(value)
    window.status=value
if value=\"True\" then
     d1.style.display=\"block\"
else
     d1.style.display=\"none\"
    end if
end sub
    </script>
  </HEAD>
  <body MS_POSITIONING=\"GridLayout\">
    <form name=\"card\" action=\"\" method=\"post\">
      <TABLE id=\"Table1\" style=\"Z-INDEX: 105; LEFT: 288px; WIDTH: 480px; POSITION: absolute; TOP: 192px; HEIGHT: 393px\"
        cellSpacing=\"1\" cellPadding=\"1\" width=\"480\" border=\"1\">
        <TR>
          <TD>
            <aspabel id=\"Label1\" runat=\"server\">姓名:</aspabel></TD>
          <TD>
            <input language=\"javascript\" onkeyup=\"return T1_onkeyup()\" type=\"text\" maxLength=\"4\" size=\"4\"
              name=\"T1\"></TD>
          <TD>
            <div id=\"img1\" style=\"DISPLAY:none\">
              <table id=\"img\">
                <tr>
                  <td>
                    <asp:Image id=\"Image1\" runat=\"server\" ImageUrl=\"file:///C:\\Documents and Settings\\Administrator\\桌面\\test1.JPG\"
                      Width=\"288px\" Height=\"80px\"></asp:Image></td>
                </tr>
              </table>
            </div>
          </TD>
        </TR>
        <TR>
          <TD>
            <aspabel id=\"Label2\" runat=\"server\">年龄:</aspabel></TD>
          <TD>
            <input language=\"javascript\" onkeyup=\"return T2_onkeyup()\" type=\"text\" maxLength=\"4\" size=\"4\"
              name=\"T2\"></TD>
          <TD>
            <div id=\"img2\" style=\"DISPLAY:none\">
              <table>
                <tr>
                  <td>
                    <asp:Image id=\"Image3\" runat=\"server\" ImageUrl=\"file:///C:\\Documents and Settings\\Administrator\\桌面\\test4.jpg\"
                      Width=\"288px\" Height=\"80px\"></asp:Image></td>
                </tr>
              </table>
            </div>
          </TD>
        </TR>
        <TR>
          <TD>
            <aspabel id=\"Label3\" runat=\"server\">职务:</aspabel></TD>
          <TD>
            <input type=\"text\" name=\"T3\" size=\"4\" maxlength=\"4\" LANGUAGE=\"javascript\" onkeyup=\"return T3_onkeyup()\"></TD>
          <TD>
            <Div style=\"DISPLAY: none\" id=\"img3\">
              <table>
                <tr>
                  <td><asp:Image id=\"Image5\" runat=\"server\" ImageUrl=\"file:///C:\\Documents and Settings\\Administrator\\桌面\\test3.gif\"
                      Width=\"112px\"></asp:Image></td>
                </tr>
              </table>
            </Div>
          </TD>
        </TR>
        <TR>
          <TD>
            <aspabel id=\"Label4\" runat=\"server\">等级:</aspabel></TD>
          <TD>
            <input type=\"text\" name=\"T4\" size=\"4\" maxlength=\"4\" LANGUAGE=\"javascript\" onkeyup=\"return T4_onkeyup()\"></TD>
          <TD>
            <Div style=\"DISPLAY: none\" id=\"img4\">
              <table>
                <tr>
                  <td><asp:Image id=\"Image6\" runat=\"server\" ImageUrl=\"file:///C:\\Documents and Settings\\Administrator\\桌面\\test2.summ.jpg\"></asp:Image></td>
                </tr>
              </table>
            </Div>
          </TD>
        </TR>
      </TABLE>
    </form>
  </body>
</HTML>
关于那几张图片大家可以自己改为不同的图片以显示效果
您需要登录后才可以回帖 登录 | 成为会员

本版积分规则

QQ|手机版|小黑屋|网站帮助|职业IT人-IT人生活圈 ( 粤ICP备12053935号-1 )|网站地图
本站文章版权归原发布者及原出处所有。内容为作者个人观点,并不代表本站赞同其观点和对其真实性负责,本站只提供参考并不构成任何投资及应用建议。本站是信息平台,网站上部分文章为转载,并不用于任何商业目的,我们已经尽可能的对作者和来源进行了通告,但是能力有限或疏忽造成漏登,请及时联系我们,我们将根据著作权人的要求立即更正或者删除有关内容。

GMT+8, 2024-4-25 03:27 , Processed in 0.112391 second(s), 20 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表