I have a custom validator that points to a Client side script to validate a textbox.
My date and time are separated into two textboxes - one with date in mm/dd/yyyy format and the other with time in hh:mm am/pm format.
I need to make sure the textboxes together are not greater than now. How can i accomplish this?
Here is what i have so far. what am i doing wrong?
function checkminutes(sender, args) {
var txtdate = $get('<%=FormView1.FindControl("txtdate").ClientID %>');
var txttime = $get('<%=FormView1.FindControl("txttime").ClientID %>');
var totaltime = txtdate.value + ' ' + txttime.value;
totaltime = Date(totaltime);
var d = new Date();
if (totaltime > d) {
args.IsValid = false;
}
else {
args.IsValid = true;
}
}
This is the answer that worked.
function checkminutes(sender, args) {
var txtdate = $get('<%=FormView1.FindControl("txtdate").ClientID %>');
var txttime = $get('<%=FormView1.FindControl("txttime").ClientID %>');
var totaltime = txtdate.value + ' ' + txttime.value;
totaltime = Date.parse(totaltime);
var d = new Date();
if (totaltime > d) {
args.IsValid = false;
}
else {
args.IsValid = true;
}
}