Monday 25 June 2012

requirefieldvalidator onclientside validator with with confirmation checkbox

 <script type="text/javascript">
        function che() {
            var ch = document.getElementById('<%=CheckBox1.ClientID %>');
            if (Page_ClientValidate()) {
                if (!ch.checked) {
                    alert("Please select checkbox first.");
                    return false;
                }
            }
        }   
    </script>

HTML-------------------------------------

<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
       <asp:RequiredFieldValidator id="rq1" ControlToValidate="TextBox1" ErrorMessage="Name cannot be blank" Display="Dynamic" runat="server"/>
        <asp:CheckBox ID="CheckBox1" runat="server" />
        <asp:Button ID="Button1" runat="server" Text="Button"
            OnClientClick="return che();" onclick="Button1_Click" ValidationGroup="2" />

No comments:

Post a Comment

Excel Sort values in ascending order using function TEXTJOIN

 Excel ::  Text ::  1,3,5,2,9,5,11 Result :: 1,2,3,5,5,9,11 Formula ::     TEXTJOIN ( ",",1,SORT(MID(SUBSTITUTE( A1 ,","...