Node Value and Length in IE

Hey Guys,

I’m attempting to run some checks on an input value. Initial HTML:

<div id="sdvcontainer" class="sdvcontainer hidden inline marginleft20">
	<input type="text" id="samedatevalue" value="date of event" name="samedatevalue" class="input jdpicker" onKeyDown="javascript:return dFilter(event.keyCode, this, '##/##/####');" />
</div>

After the page loads a javascript calendar function called JDPicker runs and changes it to:

<div id="sdvcontainer" class="sdvcontainer hidden inline marginleft20">
	<div class="jdpicker_w" onClick="checkDate(this);" onkeyup="checkDate(this);">
		<input type="text" id="samedatevalue" value="date of event" name="samedatevalue" class="input jdpicker" onKeyDown="javascript:return dFilter(event.keyCode, this, '##/##/####');" />
	</div>
</div>

Note: my issue only occurs on this HTML that is hard coded into the page. I have several other inputs (same element structure with the divs, etc) added later with javascript using createElement functions and my javascript works fine on those:

function checkDate(field) {
	var divfield = field;
	cleanWhitespace(divfield);
	var date = divfield.childNodes[0];
	var msgcontructor=divfield.parentNode;
	msgcontructor = msgcontructor.id;
	msgcontructor=msgcontructor+"DMsg";
	$(document).ready(function(){
		$("." + msgcontructor).slideUp(300);
	});
	var datevalue = date.nodeValue;
	var datelength = datevalue.length;
	var x = 0;
	var i;
	var otherdate;
	var registryids = new Array();
	var container = document.getElementById('registries');
	if (datelength !== 10 || datelength === "date of event" ||  datelength.substring(0,4) === "date") {
		date.style.background = "url(images/circlex.png) right 0 no-repeat";
		document.getElementById(msgcontructor).innerHTML = "<small>Please enter a date.</small>";
		if (document.getElementById('samedate').checked !== true && date.id !== "samedatevalue") {
			$(document).ready(function(){
				$("." + msgcontructor).slideDown(300);
			});
		}
		if (date.id === "samedatevalue") {
			document.getElementById(msgcontructor).innerHTML = "<small>Please enter a date.</small>";
			$(document).ready(function(){
				$("." + msgcontructor).slideDown(300);
			});
			cleanWhitespace(container);
			for(i = 1; i < container.childNodes.length; i++) {
				registryids[x] = container.childNodes.item(i).id;
				x = x + 1;
			}
			for(i in registryids) {
				document.getElementById(registryids[i] + 'DateInput').value = document.getElementById('samedatevalue').value;
				otherdate = document.getElementById(registryids[i]).getElementsByTagName('div');
				checkDate2(otherdate[0]);
			}
		}
		return false;
	} else {
		date.style.background = "url(images/check.png) right 0 no-repeat";
		if (date.id === "samedatevalue") {
			cleanWhitespace(container);
			for(i = 1; i < container.childNodes.length; i++) {
				registryids[x] = container.childNodes.item(i).id;
				x = x + 1;
			}
			for(i in registryids) {
				document.getElementById(registryids[i] + 'DateInput').value = document.getElementById('samedatevalue').value;
				otherdate = document.getElementById(registryids[i]).getElementsByTagName('div');
				checkDate2(otherdate[0]);
			}
		}
		return true;
	}
}

My problem is only in IE (testing with v 8). When I try to get the child elements value it gives me this error: “value null or is not an object”. I tried using .nodeValue after that and it worked, but then started giving me errors regarding the .length function “length null or is not an object”. There is no nodeLength function that I’m aware of so I’m stumped. :frowning:

Can you please provide a test web page so that we may experience the problem too, from which we can diagnose a solution for you?