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>
  • 相关阅读:
    Java之事件处理
    Java之图形程序设计
    小议设置path环境变量
    关于JAVA中的编译和解释执行
    并发工具类 CountDownLatch
    线程池
    Properties的小问题
    转换流
    TCP中客户端和服务器的理解
    leetcode_160. 相交链表
  • 原文地址:https://www.cnblogs.com/zhang1997/p/8615373.html
Copyright © 2011-2022 走看看