Enabling or not a validator control using javascript

E

Eric Caron

Hi everybody,

I have a form where I have checkbox that triggers javascript code to make a
div appear. This is when the user selects "Other" in the list of choices
and we ask him to specify his choice using a textbox control. Now if the
user has selected the "Other" choice, the entry of the information in the
textbox is mandatory, so I want to be able to enable the
RequiredFieldValidator associated with the field. In the event when the
user clicks the Submit button, I can specify this on the server-side, but is
there a way to do the same thing on the client side?

Thanks for any help.

Eric.
 
L

Lucas Tam

I can specify this on the server-side, but is
there a way to do the same thing on the client side?

I believe you'll need to use a Custom Validator and write your own custom
validation javascript.
 
P

Peter Blum

Hi Eric,

I wrote a replacement to Microsoft's validators that overcomes its numerous
limitations and helps you avoid writing custom code and hacks. Professional
Validation And More (http://www.peterblum.com/vam/home.aspx) includes the
"Enabler" property on each of its 22 validators. You assign to the Enabler
property a rule that determines if the validator is enabled or not based on
other conditions on the page. There are over 25 rules including tests for
controls visibility and enabled state.

So, you add my version of the RequiredFieldValidator to your page, establish
the Enabler to detect visibility of the textbox, and you will have client
and server side support immediately. This framework supports client-side
validation on many more browsers than the Microsoft validators, such as
Netscape/Mozilla/FireFox, Opera 7, and Safari (in addition to IE and
IE/Mac). It includes a utility to quickly convert a page from Microsoft
validators to my validators.

--- Peter Blum
www.PeterBlum.com
Email: (e-mail address removed)
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,125
Latest member
VinayKumar Nevatia_
Top