[C#] asp.net 环境下当javascript验证不通过是禁止button按钮执行onclick事件 →→→→→进入此内容的聊天室

来自 , 2021-03-02, 写在 C#, 查看 114 次.
URL http://www.code666.cn/view/bf56a1b3
  1. <script type ="text/javascript" language="javascript">
  2.            function checkInput() {        
  3.           var strMsg = "";
  4.           var userName = document.getElementById("<%=txt_Uer.ClientID%>").value;
  5.           var password = document.getElementById("<%=txt_Password.ClientID%>").value;
  6.           var txt_key = document.getElementById("<%=txt_key.ClientID%>").value;      
  7.           if (userName == "" || userName == null) {
  8.               strMsg = "用户名"
  9.           }
  10.           if (password == "" || password == null) {
  11.               strMsg += " 密码"
  12.           }
  13.           if (txt_key == "" || txt_key == null) {
  14.               strMsg += " 验证码"
  15.           }
  16.           if (strMsg != "") {
  17.               alert(strMsg + " 不能为空!");
  18.               return false;
  19.           }
  20.       }
  21.     </script>
  22.  
  23.    <asp:Button ID="Button1" runat="server" Text="登录" onclick="Button1_Click" OnClientClick="return checkInput()" />
  24. //csharp/6044

回复 "asp.net 环境下当javascript验证不通过是禁止button按钮执行onclick事件"

这儿你可以回复上面这条便签

captcha