...

View Full Version : undefined is null or not an object in a validator



jwmott
07-21-2010, 08:48 PM
Hello all. I am trying to track down why this custom validator is failing with an error that args is undefined. There are two funnctions - one works and one does not. Here they are: the bold italicized item is where the error is being generated. Function validHygieneNote works as expected however.


function validClothingNote(val,args)
{
var radio_choice = false;
var chks = document.getElementById('clothingNote');
var chks2 = document.getElementsByName('clothingInadequate');

for (counter=0; counter < chks2.length; counter++) {
if (chks2[counter].checked){
var rad_val =chks2[counter].value;
}}


if((rad_val==1)|| (rad_val==2)) {

if ((chks.value=="") || (chks.value.length==0) || (chks.value==null)){
args.IsValid=false;
}
else {
args.IsValid = true;
}
}}

function validHygieneNote(val,args)
{
var radio_choice = false;
var chks = document.getElementById('hygieneNote');
var chks2 = document.getElementsByName('hygieneInadequate');

for (counter=0; counter < chks2.length; counter++) {
if (chks2[counter].checked){
var rad_val =chks2[counter].value;
}}


if((rad_val==1)|| (rad_val==2)) {

if ((chks.value=="") || (chks.value.length==0) || (chks.value==null)){
args.IsValid=false;
}
else {
args.IsValid = true;
}
}}

jwmott
07-21-2010, 09:18 PM
Found the problem. I was calling the function without any args on another place in the form.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum