简体   繁体   中英

How do I clear controls when using required field validator?

I have a form with a number of textboxes and dropdownlist .. I have a clear Button which upon clicking is supposed to clear all the fields. But since i have required field validators and regular expressions validator on the form I am not able to fire click event unless all validation are satisfied.

You can use the CausesValidation property

<asp:Button ID="BtnClearForm"
                Text="clear form"
                CausesValidation="False"
                OnClick="BtnClearForm_Click"
                runat="server"/>

Another option is to use javascript to clear your inputs .

将clear按钮的CausesValidation属性设置为false。

try this:

CausesValidation of clear button must be false .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM