首页 > 代码库 > Reset RequiredFieldValidator 重置 验证控件

Reset RequiredFieldValidator 重置 验证控件

<td style="width:100px;">姓名<span class="must_star">*</span></td>
   <td>
    <asp:TextBox ID="txtNAME" runat="server" MaxLength="60"></asp:TextBox>
    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"  ForeColor="Red"   Display="Dynamic"
    ControlToValidate="txtNAME" ErrorMessage="请输入姓名"></asp:RequiredFieldValidator>
    </td>
  </tr>

 

 

<input id="Reset1" type="reset" value="http://www.mamicode.com/重置" class="button_blue" onclick="resetForm();" />

 

 

<script type="text/javascript">

  function resetForm() {
   //alert("test if function gets fired");
   document.forms[0].reset();
   for (i = 0; i < Page_Validators.length; i++) {
    //    Page_Validators[i].style.visibility = ‘hidden‘;
    Page_Validators[i].style.display = ‘none‘; //for  Display="Dynamic"
   }
   return false;
  }

</script>