zoukankan      html  css  js  c++  java
  • asp.net button 提交前验证

    1. js:
      1. <script type="text/javascript">   
      2.         function test() {   
      3.             var isCheck = document.getElementById('checkbox').checked;   
      4.             if (isCheck) {   
      5.           //Page_ClientValidate('submit'),这里有不同的ValidGroup,所以Page_ClientValidate传递是指定的GroupName   
      6.                 if (Page_ClientValidate('submit')) {   
      7.                      alert('验证成功');   
      8.                     return true;   
      9.                  }   
      10.              }   
      11.             else {   
      12.                  alert('您必须同意注册协议');   
      13.                 return false;   
      14.              }   
      15.   
      16.             return false;   
      17.          }   
      18.      </script>  
      1. <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>  
      2.        <asp:Button ID="Button1" runat="server" Text="Button" ValidationGroup="submit" CausesValidation="True"  
      3.            OnClientClick="return test();" OnClick="Button1_Click" />  
      4.        <input type="checkbox" id="checkbox" />我已阅读注册协议   
      5.        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1"  
      6.            Display="Dynamic" ErrorMessage="不能为空" ValidationGroup="submit"></asp:RequiredFieldValidator>  
      <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <asp:Button ID="Button1" runat="server" Text="Button" ValidationGroup="submit" CausesValidation="True" OnClientClick="return test();" OnClick="Button1_Click" />
  • 相关阅读:
    python 列表
    pytho set集合
    python 字典
    并发编程(原理篇 上)
    面向对象分析方法
    python 小记 整数与小数id
    python入门 第二天笔记
    python 元组问题解决
    python入门第一天作业。讲师写的代码。
    python学习笔记enumerate()与range(len)运用及赋值小计
  • 原文地址:https://www.cnblogs.com/tyf0422/p/2986558.html
Copyright © 2011-2022 走看看