zoukankan      html  css  js  c++  java
  • 表单是否为空验证

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
    
    <!DOCTYPE html>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <script src="JS/jquery-3.3.1.min.js"></script>
         <script>
             $(function () {
                 $("#txtUserName").blur(function () {
                     val = $(this).val();
                     if (val.length == 0) {
                         $(this).next().show();
                     }
                     else {
                         document.getElementById("s1").style.display = "none";
                     }
                 });
    
                 $("#txtpwd").blur(function () {
                     val = $(this).val();
                     if (val.length == 0) {
                         $(this).next().show();
                     }
                     else {
                         document.getElementById("s2").style.display = "none";
                     }
                 });
    
                 $("#txtconfirm").blur(function () {
                     val = $(this).val();
                     if (val.length == 0) {
                         $(this).next().show();
                     }
                     else {
                         document.getElementById("s3").style.display = "none";
                     };
                     //$("#form1").submit(function () {
    
                     //    $("#txtpwd").blur();
                     //    $("#txtconfirm").blur();                        
                     //})
                 })
             })
        </script>
        <title></title>
        <style>
            span {
                display: inline-block;
            }
    
            #s1, #s2, #s3 {
                color: #f00;
                display: none;
            }
        </style>  
    </head>
    <body>
        <form id="form1" runat="server">
            <div>
                用户名:&nbsp;        
                <asp:TextBox ID="txtUserName" runat="server"></asp:TextBox>
                 <span id="s1">*用户名不能为空</span><br />&nbsp; 码:&nbsp; 
            <asp:TextBox ID="txtpwd" runat="server" TextMode="Password"></asp:TextBox>
                <span id="s2">*密码不能为空</span><br />
                确认密码:
            <asp:TextBox ID="txtconfirm" runat="server"></asp:TextBox>
                <span id="s3">*密码不能为空</span><br />&nbsp; 箱:&nbsp; 
            <asp:TextBox ID="txtemail" runat="server"></asp:TextBox>
                <br />&nbsp; 别:       
            <asp:RadioButton ID="rabtnman" runat="server" GroupName="a" Text="" />
                <asp:RadioButton ID="rabtnwoman" runat="server" GroupName="a" Text="" />
                <br />&nbsp; 话:&nbsp; 
            <asp:TextBox ID="txtphone" runat="server"></asp:TextBox>
                <br />
                所在城市:
                <asp:DropDownList ID="DDL" runat="server">
                    <asp:ListItem>洛阳</asp:ListItem>
                    <asp:ListItem>许昌</asp:ListItem>
                </asp:DropDownList>
                <br />&nbsp; 册:<asp:Button ID="btnsubmit" runat="server" OnClick="btnsubmit_Click" Text="注册" />
    
                <br />&nbsp; 置:<asp:Button ID="btnreset" runat="server" OnClick="btnreset_Click" Text="重置" />
            </div>
        </form>
    </body>
    </html>
  • 相关阅读:
    JavaScript通过正则随机生成电话号码
    (转载)JavaScript递归查询 json 树 父子节点
    JavaScript中批量设置Css样式
    (转载)Javascript removeChild()不能删除全部子节点的解决办法
    Ajax技术实现页面无刷新跳转
    (转载)js(jquery)的on绑定点击事件执行两次的解决办法
    Chrome浏览器 js 关闭窗口失效解决方法
    JavaScript随机数区间限制
    100天搞定机器学习|Day55 最大熵模型
    50行Python代码实现视频中物体颜色识别和跟踪(必须以红色为例)
  • 原文地址:https://www.cnblogs.com/zhang1997/p/8615373.html
Copyright © 2011-2022 走看看