If you are using asp button, then the javaScript need to be called on the event
OnClientClick[
^].
Then on that call javaScript function to validate like below...
<asp:Button ID="Button1"
text="Open Web site"
onclientclick="return Validate()"
runat="server" onclick="Button1_Click" />
Now the javaScript function will validate and return appropriate boolean value like below...
function Validate(){
if validated
return true;
else
return false;
}
So, when it is not validated it will return false and the service side event
Button1_Click
will not fire and if it returns true, then the server side event will get fired.