1

我写了这个:

    <%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" Inherits="Register" Codebehind="Register.aspx.cs" %>
<asp:Content ID="Content1" ContentPlaceHolderID="myMainPage" runat="server">
 <script type="text/javascript">
       function checkInput() {
         var isInputCorrect = true;
         var Name = document.getElementById("<%=UserName.ClientID %>").value;
         var email = document.getElementById("<%=email.ClientID %>").value;
         var password = document.getElementById("<%=Password.ClientID %>").value;
         $(document).ready(function () {
             if (Name.length > 5) {
                 if ((email.length > 6) && (email.indexOf('@') != -1)) {
                     if (password.length < 5) {
                         alert("Password is too short, try again");
                         isInputCorrect = false;
                     }
                 }
                 else {
                     alert("E-mail is invaild");
                     isInputCorrect = false;
                 }
             }
             else {
                 alert("Username is too short, try again");
                 isInputCorrect = false;
             }
         });
         if (!isInputCorrect) {
             location.href = "register.aspx";

         }
         return (isInputCorrect);
     }
    </script>
        <form id="Form2" runat="server">
        <div id="Signup">
            <asp:TextBox ID="UserName" MaxLength="20" runat="server" CssClass="username" TextMode="SingleLine" value="Username" onClick="this.value=''"></asp:TextBox>
            <asp:TextBox ID="email" MaxLength="20" runat="server" CssClass="Email" TextMode="SingleLine" value="Email" onClick="this.value=''"></asp:TextBox>
            <asp:TextBox ID="Password" runat="server" CssClass="password" TextMode="Password" value="Password" onClick="this.value=''"></asp:TextBox>
            <asp:Button ID="RegisterButt" runat="server" Text="Register" OnClientClick="javascript:return checkInput();" onclick="RegisterButt_Click" />

        </div>
    </form>
</asp:Content>

但这不会进入“Chekinput”功能,有人知道吗?我在按钮命令中发送了标签的值,我不明白为什么它不能工作

4

0 回答 0