Disable all client side validation in an Asp.Net site

2.3k Views Asked by At

I would like to disable all client side validation in an Asp.Net web site in order to test that server side validation is correct (i.e. I want to test against people altering the response or tampering with client script)

Currently, I am either-

  • Disabling JS in the browser
  • Manually disabling client validation for individual validators.

Is there a global setting for this?

3

There are 3 best solutions below

0
sly_Chandan On

You can disable javascript in your browser and that will help you to check server side validation. There is no global setting for this.

0
Waqas Raja On

You can do it by a simple hack in javascript.

As the asp.net client side validation adds a attribute to form tag that is onsubmit so you need to remove it by placing the script on your master page header section.

<script type="text/javascript">
    window.onload = function () {
        if (document.forms[0].name == 'aspnetForm') {
            document.forms[0].onsubmit = '';
        }
    }
</script>
0
RahulGo8u On

It's better to use 'novalidate' keyword in your form tag. It specifies that the browser will not validate the form data on submission. So this will skip the client-side validation.