script type="text/javascript">
function HasPageValidators()
{
var hasValidators = false;
try
{
if (Page_Validators.length > 0)
{
hasValidators = true;
}
}
catch (error) { }
return hasValidators;
}
function ValidationGroupEnable(validationGroupName, isEnable)
{
if (HasPageValidators())
{
for(i=0; i < Page_Validators.length; i++)
{
if (Page_Validators[i].validationGroup == validationGroupName)
{
ValidatorEnable(Page_Validators[i], isEnable);
}
}
}
}
<form id="form1" runat="server">
<div>
<input type="button" value="Disable required field validators!" önclick="ValidationGroupEnable('vgRequiredFields', false)" /> <input type="button" value="Enable required field validators!" önclick="ValidationGroupEnable('vgRequiredFields', true)" />
<table>
<tr>
<td style="width: 229px">
<asp:Label ID="lblName" runat="server" Text="Name: " />
<asp:TextBox ID="txtName" runat="server" />
<asp:RequiredFieldValidator ID="rfvName" runat="server" ErrorMessage="*" ControlToValidate="txtName" ValidationGroup="vgRequiredFields" />
</td>
</tr>
<tr>
<td style="width: 229px">
<asp:Label ID="lblEmail" runat="server" Text="Email: " />
<asp:TextBox ID="txtEmail" runat="server"/>
<asp:RequiredFieldValidator ID="rfvEmail" runat="server" ErrorMessage="*" ControlToValidate="txtEmail" ValidationGroup="vgRequiredFields" />
<asp:RegularExpressionValidator ID="revEmail" runat="server"ErrorMessage="!" ControlToValidate="txtEmail" ValidationGroup="vgRegularExpressions"ValidationExpression="^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$" />
</td>
</tr>
</table>
</div>
</form>