I need to ensure that a user cannot enter a finish date before the start date in a form validation process. I am writing JavaScript code with a custom validator, but I keep encountering a runtime error stating 'CheckDate is undefined'.
Although my code seems correct, there might be something small that I am missing. Any assistance would be greatly appreciated.
Below is the JavaScript code written within script tags:
function CheckDate(sender, args) {
if (new Date(document.getElementById("txtstartdate").value)
> new Date(document.getElementById("TxtFinish").value)) {
args.IsValid = false;
return;
}
args.IsValid = true;
}
This is how I have set up the validation for the Finish Date control:
<asp:CustomValidator ID="CustomValidator29" runat="server"
ErrorMessage="Finish Date should be greater than the Start Date" ClientValidationFunction="CheckDate"></asp:CustomValidator>
If you require any further information, feel free to ask :).