Author: dtromp | Posted on: 3/26/2009 7:55:50 PM | Views : 393

Hi,

I got a CheckBoxList that I want to validate as one CheckBox should be selected. Since the RequiredFieldValidator does not work, I decided to use a CustomValidator to check if something was checked.

Strange enough this didn't seemed to work. It seemed like Args.IsValid = False did not got passed back to the website so it validated even when nothing was selected. Rather than looking into that, I decided to use a simple JavaScript to do the validation. Using the CustomValidator to tricker the JavaScript but this doesn't work either. I keep getting the following error:

'document.getElementById(...)' is null or not an object

and then the website validates even when no CheckBox is checked.

This is the JavaScript:

function CheckItem(sender, args) {
var chkControlId = 'CheckBoxListLocation'
var options = document.getElementById(chkControlId).getElementsByTagName('input');
var ischecked = false ...

Go to the complete details ...