ASP.NET Validation - How to disable client script

Disable client script in validation
The following asp.net c# tutorial code demonstrates how we can disable the client script in validation. In this tutorial, we used a RequiredFieldValidator control to validate a TextBox. In the RequiredFieldValidator web server control, we disabled the client script. The RequiredFieldValidator web server control makes the associated input control a required field.

The RequiredFieldValidator EnableClientScript property gets or sets a value indicating whether client-side validation is enabled. The EnableClientScript property value is a Boolean. This property value is true if client-side validation is enabled otherwise the value is false. The default value is true.

So, using this EnableClientScript property, the asp.net developers can disable the client script while validating the web page. They just have to set this property value to false.

The asp.net c# developers can use the EnableClientScript property to specify whether client-side validation is enabled. By default, this property value is set to true which enables client-side validation if the browser supports it. The developers can disable client-side validation on a control-by-control basis.

The asp.net Validation controls always perform validation on the server. Asp.net also has a complete client-side implementation that allows DHTML-supported browsers.
DisableClientScript.aspx

<%@ Page Language="C#" %>

<!DOCTYPE html>

<script runat="server">
    protected void Button1_Click(object sender, System.EventArgs e) {
        Label1.Text = "Your City: " +
            TextBox1.Text.ToString();
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Validation example: how to disable client script</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="DarkBlue"></asp:Label>
        <br />
        <asp:Label ID="Label2" runat="server" Text="City Name" AssociatedControlID="TextBox1"></asp:Label>
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <asp:RequiredFieldValidator
             ID="RequiredFieldValidator1"
             runat="server"
             ControlToValidate="TextBox1"
             ErrorMessage="Input City Name!"
             EnableClientScript="false"
             >
        </asp:RequiredFieldValidator>
        <br />
        <asp:Button ID="Button1" runat="server" Text="Submit City" OnClick="Button1_Click" />
    </div>
    </form>
</body>
</html>
Related asp.net example