I have the following JQuery code in asp.net web form:-
  <script type="text/javascript">
     function ValidateFields(id) {
               $("#Rpt1").find("input[type=text]").each(function () {
                if ($.trim($(this).val()) == '') {
                    alert("At least one textbox is empty");
                    $(this).focus(); // focus the element
                    return false;
            }
          return false;
            })
         }
     </script>
      and on asp.net button click I have the following code:-
      <asp:Button ID="BtnSubmit" runat="server" OnClientClick="if 
      (ValidateFields('BtnSubmit') == false) return(false);" 
      OnClick="BtnSubmit_Click"  Text="Submit" />
The problem is it always fires the onclick event whether the condition is true or false.
I tried many things like OnClientClick="ValidateFields('BtnSubmit');" and OnClientClick="ValidateFields('BtnSubmit'); return false;"
but nothing works. The problem is in the code of jquery
Please help.
 
    