@@ -233,6 +233,7 @@ Use a `<ListView>` to show tasks below the input field.
233
233
* Replace the ` countries ` -related binding with a binding to your array of active tasks.
234
234
* In the ` <script> ` block, remove the array of countries and create an empty array for your active tasks.
235
235
1 . In the ` <scripts> ` block, tie some logic to the tapping of the button.
236
+ * Check if the input is an empty string.
236
237
* Log newly added tasks in the console.
237
238
* Add newly added tasks into the array of active tasks. Use ` unshift ` to place new items at the top of the page.
238
239
* Clear the text field after input.
@@ -279,6 +280,7 @@ export default {
279
280
},
280
281
281
282
onButtonTap () {
283
+ if (this .textFieldValue === " " ) return ; // Prevents users from entering an empty string.
282
284
console .log (" New task added: " + this .textFieldValue + " ." ); // Logs the newly added task in the console for debugging.
283
285
this .todos .unshift ({ name: this .textFieldValue }); // Adds tasks in the ToDo array. Newly added tasks are immediately shown on the screen.
284
286
this .textFieldValue = " " ; // Clears the text field so that users can start adding new tasks immediately.
@@ -420,6 +422,7 @@ export default {
420
422
},
421
423
422
424
onButtonTap () {
425
+ if (this .textFieldValue === " " ) return ; // Prevents users from entering an empty string.
423
426
console .log (" New task added: " + this .textFieldValue + " ." ); // Logs the newly added task in the console for debugging.
424
427
this .todos .unshift ({
425
428
name: this .textFieldValue
@@ -569,6 +572,7 @@ export default {
569
572
},
570
573
571
574
onButtonTap () {
575
+ if (this .textFieldValue === " " ) return ; // Prevents users from entering an empty string.
572
576
console .log (" New task added: " + this .textFieldValue + " ." ); // Logs the newly added task in the console for debugging.
573
577
this .todos .unshift ({
574
578
name: this .textFieldValue
0 commit comments