HTML and CSS Reference
In-Depth Information
FIGURE 6-14 The Debug window.
As you can see in the figure, the Output window offers a drop-down list for you to pick up
the report you need, whether it is about debug or build.
Validating input data
The final step of the TodoList application is to collect input data and summarize that for the user,
which allows them to be able approve the result before opting to save the changes. When the user
clicks the Add Task button, the program should validate and then process the data. In this example,
you won't be doing any work yet on storage, so the task the user has defined will not be saved
anywhere. However, validation and summary of the information are two features worth discussing
right away.
Open the todolist.js file and edit the code of the TodoList.addTaskClick function, as shown below:
TodoList.addTaskClick = function () {
var currentTask = TodoList.getTaskFromUI();
if (!TodoList.validateInput(currentTask)) {
TodoList.alert("There is something wrong with the data you entered.");
For now, focus on the TodoList.validateInput function. The function receives a Task object that
has been created and populated with the data entered through the user interface. You also add the
following code to the todolist.js file:
TodoList.validateInput = function (task) {
// Check description is NOT empty
if (task.description.length == 0)
return false;
// Check date is a future date
if (task.dueDate <= new Date())
Search WWH ::

Custom Search