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:
Expand|Select|Wrap|Line Numbers
- 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;
Expand|Select|Wrap|Line Numbers
- 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