jquery
  • asp.net
  • requiredfieldvalidator
  • 2013-03-04 54 views 0 likes 
    0

    在一個頁面我有兩個單選按鈕,選擇一個我會通過使用稱爲'人'和'組織'的類在這個頁面顯示一些控件。此外,我想檢查用戶在輸入文本控件中輸入正確的數據。我如何在客戶端驗證數據? 例如:如何禁用和啓用RequiredFieldValidator控件與jquery

    <input runat="server" id="txtnationalid" maxLength="10" name="txtnationalid" class='person ltr glow-onfocus customerCode required number' dir="ltr" /> 
    <asp:RequiredFieldValidator Display="Dynamic" runat="server" ID="txtcodecv1" ErrorMessage="it can not be null" ControlToValidate="txtnationalid" ></asp:RequiredFieldValidator> 
    <asp:RegularExpressionValidator ValidationExpression="[0-9]{10}" Display="Dynamic" runat="server" id="txtcodev2" ErrorMessage="it's not in correct format" ControlToValidate="txtnationalid" ></asp:RegularExpressionValidator> 
    <input runat="server" id="txteconomiccode" maxLength="15" name="txteconomiccode" class='organization ltr glow-onfocus customerCode required number' dir="ltr" /> 
    <asp:RequiredFieldValidator Display="Dynamic" runat="server" id="txtcodecv3" ErrorMessage="economiccode required" ControlToValidate="txteconomiccode"></asp:RequiredFieldValidator>       
    
    +0

    http://stackoverflow.com/questions/9704039/enable-disable -aspvalidators-using-jquery#answer-9803857 – 2013-03-04 12:25:41

    回答

    0

    你可以使用jQuery這個

    <script> 
        $(document).ready(function(){ 
        $("#commentForm").validate(); 
        }); 
        </script> 
    
    </head> 
    <body> 
    
    
    <form class="cmxform" id="commentForm" method="get" action=""> 
        <input type="text" name="firstName" class="required"/> 
    <input type="submit" value="submit"/> 
    </form> 
    </body> 
    </html> 
    

    see here爲模式的詳細信息

    +0

    它如何驗證我的控件? (例如文本框) – Farhad 2013-03-04 12:30:50

    相關問題