• 注册表单验证


    <script type="text/javascript" language="javascript">
    //工号
    function checkGongHao()
    {
        var txtGongHao = document.getElementById("<%=txtGongHao.ClientID %>").value;
        if(txtGongHao.length == 0 || txtGongHao == "")
        {
            document.getElementById("gonghao").innerHTML="<font style='color:red;font-size:12px;'>请输入您的工号!</font>";
            document.getElementById("gonghao").style.background="url(../images/error.gif) #fff2e9 no-repeat 0px 2px";
            return false;
        }
        document.getElementById("gonghao").innerHTML="<font style='color:red;font-size:12px;'>输入正确!</font>";
        document.getElementById("gonghao").style.background="url(../images/right.gif) #e9ffeb no-repeat 0px 2px";
        return true;
    }
    //姓名
    function checkName()
    {
        var txtName = document.getElementById("<%=txtName.ClientID %>").value;
        if(txtName.length == 0 || txtName == "")
        {
            document.getElementById("name").innerHTML="<font style='color:red;font-size:12px;'>请输入您的姓名!</font>";
            document.getElementById("name").style.background="url(../images/error.gif) #fff2e9 no-repeat 0px 2px";
            return false;
        }
        document.getElementById("name").innerHTML="<font style='color:red;font-size:12px;'>输入正确!</font>";
        document.getElementById("name").style.background="url(../images/right.gif) #e9ffeb no-repeat 0px 2px";
        return true;
    }
    //密码
    function checkPwd()
    {
        var txtPwd = document.getElementById("<%=txtPwd.ClientID %>").value;
        if(txtPwd.length == 0 || txtPwd == "")
        {
            document.getElementById("pwd").innerHTML="<font style='color:red;font-size:12px;'>请输入您的密码!</font>";
            document.getElementById("pwd").style.background="url(../images/error.gif) #fff2e9 no-repeat 0px 2px";
            return false;
        }
        document.getElementById("pwd").innerHTML="<font style='color:red;font-size:12px;'>输入正确!</font>";
        document.getElementById("pwd").style.background="url(../images/right.gif) #e9ffeb no-repeat 0px 2px";
        return true;
    }
    //密码2
    function checkPwd2()
    {
        var txtPwd = document.getElementById("<%=txtPwd.ClientID %>").value;
        var txtPwd2 = document.getElementById("<%=txtPwd2.ClientID %>").value;
        if(txtPwd.length == 0)
        {
            return false;
        }
        if(txtPwd != txtPwd2 || txtPwd2.length == 0)
        {
            document.getElementById("pwd2").innerHTML="<font style='color:red;font-size:12px;'>输入密码不一致!</font>";
            document.getElementById("pwd2").style.background="url(../images/error.gif) #fff2e9 no-repeat 0px 2px";
            return false;
        }
        document.getElementById("pwd2").innerHTML="<font style='color:red;font-size:12px;'>输入正确!</font>";
        document.getElementById("pwd2").style.background="url(../images/right.gif) #e9ffeb no-repeat 0px 2px";
        return true;
    }
    function checkAddUser()
    {
        if(checkGongHao() && checkName() && checkPwd() && checkPwd2())
        {
            return true;
        }
        return false;
    }

    <table class="zuce_table">
      <tr>
        <td class="tdLeft">工号:</td>
        <td class="tdRight"><asp:TextBox ID="txtGongHao" onblur="checkGongHao()" runat="server"></asp:TextBox></td>
        <td><div id="gonghao" style="170px; text-indent:25px; padding:5px 0px;"></div></td>
      </tr>
      <tr>
        <td class="tdLeft">姓名:</td>
        <td class="tdRight"><asp:TextBox ID="txtName" runat="server" onblur="checkName()"></asp:TextBox></td>
        <td><div id="name" style="170px; text-indent:25px; padding:5px 0px;"></div></td>
      </tr>
      <tr>
        <td class="tdLeft">密码:</td>
        <td class="tdRight"><asp:TextBox ID="txtPwd" runat="server" onblur="checkPwd()" TextMode="Password"></asp:TextBox></td>
        <td><div id="pwd" style="170px; text-indent:25px; padding:5px 0px;"></div></td>
      </tr>
      <tr>
        <td class="tdLeft">确认密码:</td>
        <td class="tdRight"><asp:TextBox ID="txtPwd2" runat="server" onblur="checkPwd2()" TextMode="Password"></asp:TextBox></td>
        <td><div id="pwd2" style="170px; text-indent:25px; padding:5px 0px;"></div></td>
      </tr>
      <tr>
        <td class="tdLeft">角色:</td>
        <td class="tdRight">
            <asp:DropDownList ID="ddlRole" runat="server" Width="154">
                <asp:ListItem>用户</asp:ListItem>
                <asp:ListItem>管理员</asp:ListItem>
            </asp:DropDownList>
        </td>
        <td><div id="Div4"></div></td>
      </tr>
      <tr>
        <td colspan="3" align="center">
            <asp:ImageButton ID="imbBtnAdd" runat="server" ImageUrl="~/images/bt_zuce.gif" OnClientClick="return checkAddUser()" onclick="imbBtnAdd_Click" />
        </td>
        </tr>
    </table>

  • 相关阅读:
    Python—模块
    Python之路_Day5
    Python之路_Day4
    Py获取本机指定网卡的ip地址
    Python之路_Day3
    Python之路—Day2作业
    Python之路—Day2
    Python之路—Day1作业
    Python之路—Day1
    Python数据类型
  • 原文地址:https://www.cnblogs.com/zhengguangITelite/p/2349587.html
Copyright © 2020-2023  润新知