按钮发送服务器请求前执行下面js:
<script language="javascript">
function validatelead() {
if (document.getElementById("<%=leadTextBox1.ClientID %>").value == "" || document.getElementById("<%=leadTextBox2.ClientID %>").value == "" || document.getElementById("<%=leadTextBox3.ClientID %>").value == "") {
if (document.getElementById("<%=leadTextBox1.ClientID %>").value == "") {
alert("请输入名字");
}
if (document.getElementById("<%=leadTextBox2.ClientID %>").value == "") {
alert("请输入手机");
}
if (document.getElementById("<%=leadTextBox3.ClientID %>").value == "") {
alert("请输入邮箱");
}
return false;
}
return true;
}
</script>
<asp:Button ID="Button1" runat="server"
Text=" " class="btn-submit" OnClientClick="return validatelead()" onclick="Button1_Click"/>
注意OnClientClick="return validatelead()"
validatelead()返回bool值