I’ve checked other code, and it looks like I just need to add return false to make it work. But, it’s not working because it still posts back the page.
<asp:Button ID="_btnSearch" Text="Search"
onclientclick="CheckForEmptySearchBox()" />
<script type = "text/javascript">
function CheckForEmptySearchBox()
{
var boxContent = document.getElementById
("_ctl0_contentMain__lvTSEntry_ctrl0__txtClientName").value;
if (boxContent == null || boxContent == "") {
alert("Please enter search criteria");
return false;
}
}
</script>
The source of onclientclick is receiving
nullrather thanfalsebecause you’re not returning the result of the function call.