When an interactive web site deals with an international audience, getting the user to
enter a date can be problematic, because in North America, they express a date
as month, day, year. Thus, '03/01/01' is interpreted as the First of March, rather
than the Third of January.
One approach to solving any confusion is to put an instruction on the form asking for
the date to be entered in a particular format. Of course a user could ignore this
instruction.
Another approach is to use dropdown
select lists, as below.
Date:
However this approach is not infallible, because it would be possible to
select an invalid date, e.g. 31 February. Checking that the the date is valid
is still required after the data is submitted to the server.
If one is able to guarantee that the site's users have Javascript enabled on
their browser, as is usually the case on an Intranet, then the solution below
can be used to get a valid date every time.
Clicking on the calendar icon launches a popup calendar. The user just clicks the
required date and it is returned to the form. The only programming required is to
tell the calendar which field of the form to return the date to.
Example:
<input name="birthdate" "type="text" size="11" onclick="this.blur();">
<a href="javascript:calendar('birthdate');">
<img src="images/calicon.gif" border="0"></a>
The following script needs to placed in the head section of the page:
<script language="Javascript">
function calendar(datefield){
var val=escape(document.forms[0].elements[datefield].value);
window.open('calendar.asp?fld='+datefield+'&val='+val, 'calendar', 'width=240,height=270,menubar=0,scrollbars=0,resizable=1,toolbar=0');
}
</script>
See how it works by pressing the calendar icon below.
Birth Date:
You can download this program by clicking the link below.
|