I have a web form for data entry. The page requires an ID to be passed via query string. In the code behind I check the ID has been supplied. If it hasn't the form (in a panel) is hidden and an error message is displayed.
In the html I have a JQuery script block that attaches an event (downloaded date picker).
window.onload = function() {
new JsDatePick({
useMode: 2,
target: "txtDateOfIncident",
dateFormat: "%d %M %Y"
});
};
If the code behind hides the form the JQuery throws an error Object Required
So in the JQuery I am trying to test existance of the object As per this post...
window.onload = function() {
if ($('#txtDateOfIncident').length) {
new JsDatePick({
useMode: 2,
target: "txtDateOfIncident",
dateFormat: "%d %M %Y"
});
}
};
Now I get the Object Required
error on the $('#txtDateOfIncident').length
code.
Any help to resolve this would be appreciated.