Requiredfieldvalidator

VBdotnet2005
VBdotnet2005 used Ask the Experts™
on

I want to use Requiredfieldvalidator to check Dropdownlist. Initial value of Dropdownlist is "Select.." I wan do this easily. However, I have checkbox also. Is there a way to ignore validation if Checkbox is checked? Or is the a approach?

Dropdownlist  Checkbox      label       Requiredfieldvalidator
Dropdownlist  Checkbox      label       Requiredfieldvalidator
Dropdownlist  Checkbox      label       Requiredfieldvalidator
Dropdownlist  Checkbox      label       Requiredfieldvalidator
Dropdownlist  Checkbox      label       Requiredfieldvalidator
Dropdownlist  Checkbox      label       Requiredfieldvalidator
Dropdownlist  Checkbox      label       Requiredfieldvalidator
Dropdownlist  Checkbox      label       Requiredfieldvalidator


etc
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
client side logic
==============
Default, all required field validators are enabled
Trap checkbox checked event, disable/enable validator using ValidatorEnable(ClientID_validator, false) or ValidatorEnable(ClientID_validator, false)

Server side logic
=============
in Page load, loop through all checkboxes and disable required field validators for selected checkboxes

Reference
http://forums.asp.net/p/1562044/3874457.aspx#3874457
it's better if you go with javascript validation!

it'll be achieved easily in this way, just need to check the checkbox, if it's checked then dont validate dropdown. you can place a button and register js function on click event of this button.

function validatedropdowns()
{
       if (!chk1.checked && ddl1.selectedValue == 'select..') lbl1.value = 'Validtion message for dropdown1';
       if (!chk2.checked && ddl2.selectedValue == 'select..') lbl2.value = 'Validtion message for dropdown2';
       .....................
}

let me know if you have any difficulty.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial