I have an ASP.NET form that takes input from a user. There's a Submit
button on the form and a button called Calc
which does a calculation to populate a text field. The problem I'm having is that on the form I have a set of <ASP:REQUIREDFIELDVALIDATOR>
validators and when the Calc
button is pressed the form gets validated. I don't want the required fields to be validated when the Calc
button is pressed, only the Submit
button. Any way around this?
To prevent validation from being performed, set the CausesValidation property to false . You should set the CausesValidation property to false when you are using the PostBackUrl property to post back to a different page.
To disable validation when clicking a button, set the MVC Button. CausesValidation property value to false.
To disable a validation controlSet the validation control's Enabled property to false.
To disable client-side validation, set the page's ClientTarget property to 'Downlevel' ('Uplevel' forces client-side validation). Alternatively, you can set an individual validator control's EnableClientScript property to 'false' to disable client-side validation for that specific control.
Set the CausesValidation
property to false.
<asp:Button runat="Server" ... CausesValidation="False" />
Button.CausesValidation (If I remember correctly).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With