TEL:150-0382-3679
新闻资讯 News Center
建站知识 / 公司动态
按钮执行服务器事件之前先执行js

按钮发送服务器请求前执行下面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值
一站式全网营销,您身边的网络营销顾问,为您一对一私人定制符合您实际需求的网络营销实施方案!
24小时咨询热线:
150-0382-3679