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