I am having some problem with OnClientClick.
I added a button into my webform like this.
<asp:Button ID="Button1" runat="server" onclick="Button1_Click"
style="top: 307px; left: 187px; position: absolute; height: 26px; width: 90px"
Text="Submit" OnClientClick="return validate()" />
And i am writing a javascript inside <head>
immediately after the <title>
.
<script language="javascript" type="text/javascript">
function validate() {
if (document.getElementById("<%=TextBox1%>").value == "") {
alert("textbox1 should not be empty");
}
else if(document.getElementById("<%=TextBox2 %>").value==""){
alert("textbox2 should not be empty");
}
}
</script>
TextBox1
andTextBox2
are the Id's of two textboxes.
But when i click on Submit button, OnClick is firing but OnClientClick is not firing.
Whats the problem ?
Please help.