Yes, you can do this. The way this works?
If the onclient click function returns true, then the server side code/event runs.
If the onclient click function returns false, then the server side code/event does NOT run. So you can do this:
<asp:Button Text="search" ID="search" OnClick="search_Click"
runat="server" style="float:right" onClientClick="return neki();"
And now your JS code can be this:
function neki() {
if ( $("input[id*='txtIDCriteria']").val() == ''
&& $("input*[id*='chkID']").is(':checked'))
{
alert('Value is required.');
return true;
}
return false;
}
While this will work for above, if you use a jQuery.UI dialog, the code does not wait, but there is a simple work around for even jQuery.UI dialog that respond to say a yes/no answer, and you can still conditional run the server side button code.
edit: opps - I have this backwards.
the code should be like this:
function neki() {
if ( $("input[id*='txtIDCriteria']").val() == ''
&& $("input*[id*='chkID']").is(':checked'))
{
alert('Value is required.');
return false; <--- return false to NOT run button click
}
return true; <--- return true - this will allow button click to run
}