Check client side validation

It’s possible to check whether a certain validation group is valid via Javascript code by using the function

<script type="text/javascript">

	function disableButton(btn, groupName) {
		if (Page_ClientValidate(groupName)) { //check validation
			btn.disabled = true;


<asp:TextBox ID="TextBox1" runat="server" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="*"
	ControlToValidate="TextBox1" ValidationGroup="GroupA" />

<asp:TextBox ID="TextBox2" runat="server" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="*"
	ControlToValidate="TextBox2" ValidationGroup="GroupB" />

<p />
<asp:Button ID="Button1" runat="server" Text="Button1"
	OnClientClick="disableButton(this, 'GroupA')" onclick="Button1_Click" />

One thought on “Check client side validation

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s