
DateTextBox Control
Back
The DateTextBox Control is a complete solution to date entry in a web form. It
is a greatly extended TextBox which assists the user in entering the day,
month, and year of a date. Users can popup a calendar to select a date from
that interface or use an assortment of commands available as single keystroke,
from a context menu, or from a Help button.
Product Features
The extensive feature list is shown below. Test the features yourself in the
Demos found here.
Entering data into the TextBox
Note: All of the below requires a browser that supports the client side
scripting. These features scale down or turn off in lesser browsers.
-
Supports several date formats:
All Peter's Date and Time controls use the System.Globalization.CultureInfo
object to determine the extact format. So they are fully localizable.
DEMO: The above textboxes are actual controls. Give them a try as you explore
each of these features.
<table>
<tr>
<td>Short</td>
<td>
<des:datetextbox id="DTB1A" runat="server" InitiallyBlankRule="Today"></des:datetextbox>
<des:DataTypeCheckValidator id="ValDTB1A" runat="server"
ErrorMessage="Incorrect format" ControlIDToEvaluate="DTB1A" >
<ErrorFormatterContainer>
<des:TextErrorFormatter Display="Dynamic"/>
</ErrorFormatterContainer>
</des:DataTypeCheckValidator>
</td>
</tr>
<tr>
<td>Short w/abbreviated month</td>
<td>
<des:datetextbox id="DTB1B" runat="server" AllowMonthNames="Show" TodayCommandKeys="CTRL+T" InitiallyBlankRule="Today">
<ContextMenu SharedGroup="CTRLT">
</ContextMenu>
</des:datetextbox>
<des:DataTypeCheckValidator id="ValDTB1A" runat="server"
ErrorMessage="Incorrect format" ControlIDToEvaluate="DTB1A" >
<ErrorFormatterContainer>
<des:TextErrorFormatter Display="Dynamic"/>
</ErrorFormatterContainer>
</des:DataTypeCheckValidator>
</td>
</tr>
<tr>
<td>Abbreviated</td>
<td>
<des:datetextbox id="DTB1C" runat="server" DateFormat="Abbreviated" TodayCommandKeys="CTRL+T" InitiallyBlankRule="Today">
<ContextMenu SharedGroup="CTRLT">
</ContextMenu>
</des:datetextbox>
<des:DataTypeCheckValidator id="ValDTB1A" runat="server"
ErrorMessage="Incorrect format" ControlIDToEvaluate="DTB1A" >
<ErrorFormatterContainer>
<des:TextErrorFormatter Display="Dynamic"/>
</ErrorFormatterContainer>
</des:DataTypeCheckValidator>
</td>
</tr>
<tr>
<td>Long</td>
<td>
<des:datetextbox id="DTB1D" runat="server" DateFormat="Long" TodayCommandKeys="CTRL+T" InitiallyBlankRule="Today">
<ContextMenu SharedGroup="CTRLT">
</ContextMenu>
</des:datetextbox>
<des:DataTypeCheckValidator id="ValDTB1A" runat="server"
ErrorMessage="Incorrect format" ControlIDToEvaluate="DTB1A" >
<ErrorFormatterContainer>
<des:TextErrorFormatter Display="Dynamic"/>
</ErrorFormatterContainer>
</des:DataTypeCheckValidator>
</td>
</tr>
</table>
|
-
Keystrokes are filtered to allow only the characters supported by the date
format. This is not
a "masked textbox", where the user is highly constrained to type a very
specific character at a specific position because of the next feature...
-
Has a powerful fuzzy logic parser to interpret what the user types when they do
not follow the date format precisely. Fuzzy logic allows users to enter data
more quickly as they can use shortcuts.
Here are its features:
-
The user can omit the month and year. When the user exits the TextBox, the
month and year associated with Today's date is assigned automatically. For
example, if today is 10/5/2006 (MM/dd/yyyy) and the user enters '12', it will
update with '10/12/2006'. If the user enters '11/12', it will reformat with
'11/12/2006'.
-
The user can type the first few characters of a month name and the software
will figure out the rest. For example, type "Ja 29, 2006" and it will identify
the month as January.
-
If the user omits the date separator and exits the TextBox, separators will be
added for them. The rule is that the field has at least 3 characters and there
are no date separators. For example, they can enter '905' or '90506' for
'09/05/2006' (shown with the pattern "MM/dd/yyyy" although it works in any
short date pattern.)
-
When the user exits the TextBox, the date automatically reformats to match the
date pattern rules for lead zeros on months and days, corrects a textual month
name, and assign the century when a 2-digit year is entered. For example, if
the ShortDatePattern is MM/dd/yyyy and the user types in '1/4/07', it will
reformat to '01/04/2007'.
-
You can install custom client and server side parsers to handle any date
formats and coding systems that are not built in. For example, suppose
your users need to enter +3d
as a code for "add 3 days to the current date".
-
There are numerous commands available to assist the user (especially valuable
when the user is likely to use the control frequently for data entry.) Commands
are offered as single keystrokes, from an optional right click Context Menu or
optional Help button.
The Context Menu and Help button require a license covering Peter's Interactive
Pages module.
Here are the commands:
-
Assign Today's date with the Today command. The default keystroke is 'T'.
-
Assign a special date that you might like the user to select by default. The
control can default to this date. The user can use the Special command to
assign the special date. The default keystroke is 'S'.
-
Assign the next day with the Next Day command. Several keystrokes are available
by default including down arrow,
period,
plus
and
greater than. Assign the previous day with the Previous Day command.
The keystrokes default to
up arrow,
comma,
minus, and less than.
-
Assign the next month with the Next Month command. The default keystroke is
pagedown. Assign the previous month with the Previous Month command.
The default keystroke is pageup.
-
Popup the calendar with the Popup command. The default keystroke is 'C'
-
Limit the user to dates within a minimum and maximum. With the addition of the
SpecialDates
control and UnselectableDatesValidator, prevent the user from entering specific
dates, including days of the week.
DEMO: This DateTextBox will not permit selecting either Saturday or Sunday.
Use the textbox to type dates for either day and then hit tab to see the
UnselectableDatesValidator report an error. It will even say the specific name
of the day in the error message. Popup the calendar to see how it does not
permit selection of those dates either.
It will also prevent selection of dates earlier than 3 months ago and 3 months
from now. The RangeValidator reports errors. Also, the popup Calendar and its
popup MonthYearPicker will not allow selection outside the range.
<des:datetextbox id=DTB2A runat="server" SpecialDatesControlID="SD2A" InitiallyBlankRule="Today" />
<des:DataTypeCheckValidator id="ValDTB2A" runat="server"
ErrorMessage="Incorrect format" ControlIDToEvaluate="DTB2A" >
<ErrorFormatterContainer>
<des:TextErrorFormatter Display="Dynamic"/>
</ErrorFormatterContainer>
</des:DataTypeCheckValidator>
<des:RangeValidator id="ValDTBRange" runat="server"
ControlIDToEvaluate="DTB2A" ErrorMessage="Out of range" >
<ErrorFormatterContainer>
<des:TextErrorFormatter Display="Dynamic"/>
</ErrorFormatterContainer>
</des:RangeValidator>
<des:UnselectableDatesValidator id="UnselDTB2A" runat="server"
ErrorMessage="Cannot select {DATELABEL}" ControlIDToEvaluate="DTB2A" >
<ErrorFormatterContainer>
<des:TextErrorFormatter Display="Dynamic"/>
</ErrorFormatterContainer>
</des:UnselectableDatesValidator>
<des:specialdates id=SD2A runat="server">
<des:SpecialDayOfWeek DayOfWeek="Saturday" Label="Saturdays" />
<des:SpecialDayOfWeek DayOfWeek="Sunday" Label="Sundays" />
</des:specialdates>In Page_Load method(), C#:
DTB2A.MinDate = DateTime.Today.AddMonths(-3);
DTB2A.MaxDate = DateTime.Today.AddMonths(3); In Page_Load() method,
VB:
DTB2A.MinDate = DateTime.Today.AddMonths(-3)
DTB2A.MaxDate = DateTime.Today.AddMonths(3)
|
Popup Calendar
The popup calendar features the
Calendar control.
You have access to nearly all of its 200+ properties. Here are some highlights:
-
Add buttons to move by a year. Buttons to change months can be in several
locations in the header.
-
The MonthYearPicker control appears when the user clicks on the month name. It
lets the user quickly jump to any month.
-
The calendar has several commands: Today, Show, Clear, Next Month, Prev Month,
Next Year, and Prev Year. These can be show in the optional context menu and
help button (Requires a license covering Peter's Interactive Pages module.).
They all can appear as buttons on the calendar. In Internet Explorer, users can
invoke them through the keyboard, such as "T" for Today.
-
The calendar supports extensive keyboard controls, including command
keystrokes, arrow keys to move the selection and typing digits to a date.
-
Show multiple months at once.
-
Show the currently selected date in a descriptive label at the bottom of the
calendar.
-
Extensive customization of the appearance using style sheets and alternative
graphics. A style sheet file is provided, ready for editing, along with
supporting documenation. Several images for the month change buttons are
provided, or create your own.
-
Using the SpecialDates control, you can change the format, style, and
selectability of dates within the popup calendar.
DEMO: Here are two examples. Each offers the optional Apply button which keeps
the calendars open until you click Apply. Use the close box to cancel.
<table>
<tr>
<td>Extensive customization:
<des:DateTextBox id="DTB3A" runat=server InitiallyBlankRule="Today">
<PopupCalendar >
<Calendar SharedGroup="FANCYCAL" CommandButtonCellWidth="50px" TodayButtonPlacement="FirstRow" ClearButtonPlacement="FirstRow"
ShowSelectionButtonPlacement="FirstRow" ApplyButtonPlacement="FirstRow" CurrentDatePlacement="SecondRow"
CloseButtonHorzPlacement="Right" CloseButtonVertPlacement="NextToMonth" HelpButtonHorzPlacement="Right" ShowWeekNumbers="True"
DayCellWidth="40" JumpButtonHorzPlacement="Surround" IncrementalButtonHorzPlacement="Left" HeaderButtonPairGap="15px"
HelpButtonVertPlacement="NextToMonth" DayNameFormat="FirstTwoLetters" SideGaps="10" WeekendBackground="255, 255, 192">
</Calendar>
</PopupCalendar>
</des:DateTextBox>
</td>
<td> Multiple Months View:
<des:DateTextBox id=DTB3B runat=server InitiallyBlankRule="Today">
<PopupCalendar >
<Calendar SharedGroup="TWOMONTHCAL" MultiMonthColumnCount="2" CloseButtonHorzPlacement="Right" CloseButtonVertPlacement="NextToMonth"
ApplyButtonPlacement="FirstRow" CurrentDatePlacement="FirstRow" CommandButtonCellWidth="50px" >
</Calendar>
</PopupCalendar>
</des:DateTextBox>
</td>
</tr>
</table>
|
Other Features
Back
|