Tuesday, December 14, 2010

Enable/Disable RequiredFieldValidator with Javascript

Sometimes we need to Enable or Disable validation on client side.For that use ValidatorEnable function in the Asp.net javacsript Script Library.

For that set EnableClientScript property of validator to True.

Here i give example for this:

I have a page with a couple of radio buttons.On radio button selection i want to enable/disable validation.

In example if i select Email radio button then Email div will display and only txtEmail textbox validator is enabled.

Java Script for this:



Code for this:


Email :

PhoneNo :


Email
ControlToValidate="txtEmail" EnableClientScript="true" ValidationGroup="vgSubmit" />


No comments:

Post a Comment