"If at first you don't succeed; call it version 1.0" :-Unknown

Pages

Friday, January 4, 2013

return false; is NOT working [Resolved]

return false; is NOT working

Its a common error while handling logic operation in JavaScript.
Here i'm listing a few reason 

Here chkduplicate() is my function


1.IF you are calling a function on OnClientClick event try to use return before the function 
<asp:Button ID="btnSaveFileFormat" runat="server" Text="Save File Type" class="btn_cl" OnClientClick='return chkduplicate();'
                    Style="width: 195px; float: right" ValidationGroup="saveColumnDetails" OnClick="btnSaveFileFormat_Click" />
 2.     $(document).ready(function() {
           $('#<%= btnSaveFileFormat.ClientID%>').click(function(e) 
               if (chkduplicate() == false)
                e.preventDefault();
        });});
              Its better that first method
3.   

<form onsubmit="return chkduplicate();">
OR
<form action="JAVASCRIPT:chkduplicate();"
 4.if you are using nested function don't give return false at child function instead of that give that at parent function

If u had any trouble just ask, Happy to help u :) 
Stay Tune... 
Have a nice day... 'N happy Coding :)

No comments: