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>
  • 相关阅读:
    使用JDBC连接MySql时出现:The server time zone value '�й���׼ʱ��' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration
    Mysql Lost connection to MySQL server at ‘reading initial communication packet', system error: 0
    mysql-基本命令
    C# 监听值的变化
    DataGrid样式
    C# 获取当前日期时间
    C# 中生成随机数
    递归和迭代
    PHP 时间转几分几秒
    PHP 根据整数ID,生成唯一字符串
  • 原文地址:https://www.cnblogs.com/zhang1997/p/8615373.html
Copyright © 2011-2022 走看看