[jQuery] Clash between jQuery UI datepicker 1.5.2 and an ASP.net 3.5 CustomValidator
Hello everyone,
I'm experiencing a clash between jQuery UI datepicker 1.5.2 and an
ASP.net 3.5 CustomValidator. The problem occurs in Internet Explorer
7.0, not in Firefox 2.0. When I change the date using the little drop
down calendar, IE throws the following error:
Line 172 'length' has a null value or is not an object
I did a bit of debugging in both IE and Firefox. Now, in
ui.datepicker.js on line 730, the change event is automatically
triggered once the user selects a day:
else if (inst.input)
inst.input.trigger('change'); // fire the change event
From there, jquery.js on line 2020 triggers the actual event:
if ( (!fn || (jQuery.nodeName(elem, 'a') && type == "click")) &&
elem["on"+type] && elem["on"+type].apply( elem, data ) === false )
val = false;
And finally we wind up in the ASP.net javascript, to which I have
added a few comments.
function ValidatorOnChange(event) {
if (!event) {
event = window.event;
}
Page_InvalidControlToBeFocused = null;
var targetedControl;
if ((typeof(event.srcElement) != "undefined") &&
(event.srcElement != null)) {
// Internet Explorer always enters this branch. event.srcElement
contains a reference to an
// anchor (tagName = “A”)
targetedControl = event.srcElement;
}
else {
// Firefox always enters this branch. event.target contains a
reference to the input box.
targetedControl = event.target;
}
var vals;
if (typeof(targetedControl.Validators) != "undefined") {
vals = targetedControl.Validators;
}
else {
if (targetedControl.tagName.toLowerCase() == "label") {
targetedControl =
document.getElementById(targetedControl.htmlFor);
vals = targetedControl.Validators;
}
}
var i;
// Internet Explorer fails on this line, as vals is undefined.
for (i = 0; i < vals.length; i++) {
ValidatorValidate(vals[i], null, event);
}
ValidatorUpdateIsValid();
}
I'm afraid I don't really understand javascript well enough to
determine the reason for the difference in behavior. Could anyone
else suggest why this is happening?
After some Googling, I discovered this forum post which hints at a
similar problem:
http://www.zapatec.com/website/forums/viewtopic.php?t=164
I refer specifically to jahoog's post where he says: "It seems the
problem in IE is that the '.onchange()' syntax does not pass the event
information correctly."
Could that perhaps be the problem here?
Must appreciated,
Patrick Collins
France