Hi
One of the web form has 3 dates fields: Date of form entry, date of diagnosis and date of death.
Date of form entry has future date validation done which I thought of extending to the other two date fields.
Code being used already:
I just thought I will use the same code with my date values:
It validate fine but the error message is vague and also the focus just returns to the date of form entry: date3 / date 2 or date1
Help I need?
Please tell me how can I provide a customized error message such that if the future date value if for date of entry it says: Your day value for date of entry (Similarly replace it with date of diagnosis/ date of death as applicable) can not be later than today's day.
Secondly, to return the focus, to the exact field that is wrong.
Can I pass the field values as variables and pass them instead of a fixed date1, date2 or date3 in the function that is validating for future value?
Hope I am clear, otherwise please let me know.
Thanks for your help in advance,
Sree
One of the web form has 3 dates fields: Date of form entry, date of diagnosis and date of death.
Date of form entry has future date validation done which I thought of extending to the other two date fields.
Code being used already:
Code:
function checkFutureDate(day, month, year, formName)
{
if (year > <%=zYear%>)
{
alert("Year cannot be later than the current year.");
document.frmUser.date3.focus();
return false;
}
else if ((month > <%=zMonth%>) && (year == <%=zYear%>))
{
alert("Month cannot be later than the current month.");
document.frmUser.date2.focus();
return false;
}
else if ((day > <%=zDay%>) && (month == <%=zMonth%>) && (year == <%=zYear%>))
{
alert("Day cannot be later than the current day.");
document.frmUser.date1.focus();
return false;
}
return true;
}
its been called from another function:
var ok = checkFutureDate(document.frmUser.date1.value, document.frmUser.date2.value, document.frmUser.date3.value);
if(!ok)
return false;
Code:
var ok = checkFutureDate(diagdate1, diagdate2, diagdate3); if(!ok) return false; var ok = checkFutureDate(death1, death2,death3); if(!ok) return false;
Help I need?
Please tell me how can I provide a customized error message such that if the future date value if for date of entry it says: Your day value for date of entry (Similarly replace it with date of diagnosis/ date of death as applicable) can not be later than today's day.
Secondly, to return the focus, to the exact field that is wrong.
Can I pass the field values as variables and pass them instead of a fixed date1, date2 or date3 in the function that is validating for future value?
Hope I am clear, otherwise please let me know.
Thanks for your help in advance,
Sree
Comment