Capturing the Selected Date

The DatePicker control raises the same event when you change the month, day, or year: the change event. You can retrieve the currently selected date by handling this event.

For example, the HTML page in Listing 4.10 contains a DatePicker control and a DIV element that displays the selected date (see Figure 4.17).

Image

FIGURE 4.17 Displaying the DatePicker current date

LISTING 4.10 Capturing the Selected Date (datePickerChange\datePickerChange.html)

<label>Birthday:</label><div id="dateBirthday"    data-win-control="WinJS.UI.DatePicker"></div><div id="divMessage"></div>

The JavaScript file ...

Get Windows® 8.1 Apps with HTML5 and JavaScript Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.