?
Solved

Required field depends on value of another field

Posted on 2009-06-30
3
Medium Priority
?
239 Views
Last Modified: 2012-05-07
I have a field in a formview which is required only if the user has chosen a certain option from another dropdown on the same form.  For instance, if the user chooses option 1 from the dropdown the second field is required, if they choose option 2 the second field isn't required.

Is there a way to accomplish this with the .net validators or do I have to write some client-side Javascript?

Thanks in advance!
0
Comment
Question by:AX_User
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 5

Expert Comment

by:rizwanidrees
ID: 24743743
You have to do it with your own script.
0
 
LVL 3

Accepted Solution

by:
tpsl earned 500 total points
ID: 24743745
You will have to write javascript for the same.

Write a javascript onchange event of ddl.

you will not get intellisense for onchange event in html.

in javascript you could use the ValidatorEnable method to enable disable the validator controls.
0
 
LVL 2

Assisted Solution

by:puneetdudeja
puneetdudeja earned 500 total points
ID: 24743835
You can also do it with the .net validators but with the "CustomValidator" validator only.
Use ClientValidationFunction for CustomValidator and set  ControlToValidate to your dropdown containing that values.

In ClientValidation function check the value of your dropdown and it is the value for which the other field is required than set "IsValid" property of argument "e" to false in the ClientValidation function.

ClientValidationFunction(sender,e)
{
     // If drop down value is the one that requires the other field
     // set e.IsValid=false;
}

0

Featured Post

Major Serverless Shift

Comparison of major players like AWS, Microsoft Azure, IBM Bluemix, and Google Cloud Platform

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question